using NUnit.Framework; using Platnosci.Core.Linq; using Platnosci.Core.Interface; using MvcContrib.TestHelper; using Platnosci.Controllers; using System.Web.Mvc; namespace Platnosci.Tests.Web { [TestFixture] class StatusTest { [Test] [Category("Unit")] public void FormatException_Ordernumber_Test() { IRepository repConfirm = new Repository(new FakeDataContext()); var builder = new TestControllerBuilder(); var controller = new PlatnoscController(null, null, repConfirm, null); builder.InitializeController(controller); builder.Form.Add("MERCHANTNUMBER", "132423"); builder.Form.Add("ORDERNUMBER", "32hvhsvhv"); var result = controller.Status() as ContentResult; System.Diagnostics.Debug.WriteLine("1. Zły formt ordernumber."); System.Diagnostics.Debug.WriteLine("2. Count: " + repConfirm.Count()); System.Diagnostics.Debug.WriteLine("3. Contetnt: " + result.Content); Assert.That(repConfirm.Count().Equals(0)); Assert.That(result.Content.Contains("FormatException")); } [Test] [Category("Unit")] public void FormatException_Paymenttype_Test() { IRepository repConfirm = new Repository(new FakeDataContext()); var builder = new TestControllerBuilder(); var controller = new PlatnoscController(null, null, repConfirm, null); builder.InitializeController(controller); builder.Form.Add("MERCHANTNUMBER", "132423"); builder.Form.Add("PAYMENTTYPE", "32hvhsvhv"); var result = controller.Status() as ContentResult; System.Diagnostics.Debug.WriteLine("Zły formt paymenttype. " + " Count: " + repConfirm.Count()); Assert.That(repConfirm.Count().Equals(0)); Assert.That(result.Content.Contains("FormatException")); } [Test] [Category("Unit")] public void FormatException_Eventtype_Test() { IRepository repConfirm = new Repository(new FakeDataContext()); var builder = new TestControllerBuilder(); var controller = new PlatnoscController(null, null, repConfirm, null); builder.InitializeController(controller); builder.Form.Add("MERCHANTNUMBER", "132423"); builder.Form.Add("EVENTTYPE", "32hvhsvhv"); var result = controller.Status() as ContentResult; System.Diagnostics.Debug.WriteLine("Zły formt eventtype. " + " Count: " + repConfirm.Count()); Assert.That(repConfirm.Count().Equals(0)); Assert.That(result.Content.Contains("FormatException")); } [Test] [Category("Unit")] public void OverflowException_Ordernumber_Test() { var controller = new PlatnoscController(); var builder = new TestControllerBuilder(); builder.InitializeController(controller); builder.Form.Add("MERCHANTNUMBER", "132"); builder.Form.Add("ORDERNUMBER", "12311111111111111"); builder.Form.Add("VALIDATIONCODE", "AAA"); var result = controller.Status() as ContentResult; System.Diagnostics.Debug.WriteLine("1. Wartosc ordernumber jest za duza."); System.Diagnostics.Debug.WriteLine("2. Contetnt: " + result.Content); Assert.That(result.Content.Contains("OverflowException")); } [Test] [Category("Unit")] public void IncorrectLength_Validationcode_Test() { var controller = new PlatnoscController(); var builder = new TestControllerBuilder(); builder.InitializeController(controller); builder.Form.Add("MERCHANTNUMBER", "132"); builder.Form.Add("ORDERNUMBER", "1234"); builder.Form.Add("VALIDATIONCODE", "AAAaaa"); var result = controller.Status() as ContentResult; System.Diagnostics.Debug.WriteLine("1. Validationcode jest zbyt dlugi. Conajwyzej 3 znaki."); System.Diagnostics.Debug.WriteLine("2. Contetnt: " + result.Content); Assert.That(result.Content.Contains("SqlException")); } } }