root/trunk/eCard/eCardMVC/Platnosci.Tests/Web/StatusTest.cs @ 969

Wersja 969, 4.5 KB (wprowadzona przez marek, 16 years temu)

re #215

RevLine 
[931]1using NUnit.Framework;
[911]2using Platnosci.Core.Linq;
3using Platnosci.Core.Interface;
4using MvcContrib.TestHelper;
5using Platnosci.Controllers;
6using System.Web.Mvc;
7
8namespace Platnosci.Tests.Web
9{
[969]10    [TestFixture]
11    public class StatusTest
[911]12    {
13        [Test]
14        [Category("Unit")]
15        public void FormatException_Ordernumber_Test()
16        {
17            IRepository<PotwierdzeniaEcard> repConfirm = new Repository<PotwierdzeniaEcard>(new FakeDataContext());
18            var builder = new TestControllerBuilder();
19            var controller = new PlatnoscController(null, null, repConfirm, null);
20            builder.InitializeController(controller);
21            builder.Form.Add("MERCHANTNUMBER", "132423");
22            builder.Form.Add("ORDERNUMBER", "32hvhsvhv");
23
24            var result = controller.Status() as ContentResult;           
25            System.Diagnostics.Debug.WriteLine("1. Zły formt ordernumber.");
26            System.Diagnostics.Debug.WriteLine("2. Count: " + repConfirm.Count());
27            System.Diagnostics.Debug.WriteLine("3. Contetnt: " + result.Content);
28            Assert.That(repConfirm.Count().Equals(0));
29            Assert.That(result.Content.Contains("FormatException"));
30        }
31        [Test]
32        [Category("Unit")]
33        public void FormatException_Paymenttype_Test()
34        {
35            IRepository<PotwierdzeniaEcard> repConfirm = new Repository<PotwierdzeniaEcard>(new FakeDataContext());
36            var builder = new TestControllerBuilder();
37            var controller = new PlatnoscController(null, null, repConfirm, null);
38            builder.InitializeController(controller);
39            builder.Form.Add("MERCHANTNUMBER", "132423");
40            builder.Form.Add("PAYMENTTYPE", "32hvhsvhv");
41
42            var result = controller.Status() as ContentResult;
43            System.Diagnostics.Debug.WriteLine("Zły formt paymenttype. " + " Count: " + repConfirm.Count());
44            Assert.That(repConfirm.Count().Equals(0));
45            Assert.That(result.Content.Contains("FormatException"));
46        }
47        [Test]
48        [Category("Unit")]
49        public void FormatException_Eventtype_Test()
50        {
51            IRepository<PotwierdzeniaEcard> repConfirm = new Repository<PotwierdzeniaEcard>(new FakeDataContext());
52            var builder = new TestControllerBuilder();
53            var controller = new PlatnoscController(null, null, repConfirm, null);
54            builder.InitializeController(controller);
55            builder.Form.Add("MERCHANTNUMBER", "132423");
56            builder.Form.Add("EVENTTYPE", "32hvhsvhv");
57
58            var result = controller.Status() as ContentResult;
59            System.Diagnostics.Debug.WriteLine("Zły formt eventtype. " + " Count: " + repConfirm.Count());
60            Assert.That(repConfirm.Count().Equals(0));
61            Assert.That(result.Content.Contains("FormatException"));
62        }
63        [Test]
64        [Category("Unit")]
65        public void OverflowException_Ordernumber_Test()
66        {
67            var controller = new PlatnoscController();
68            var builder = new TestControllerBuilder();
69            builder.InitializeController(controller);
70            builder.Form.Add("MERCHANTNUMBER", "132");
71            builder.Form.Add("ORDERNUMBER", "12311111111111111");
72            builder.Form.Add("VALIDATIONCODE", "AAA");
73           
74            var result = controller.Status() as ContentResult;
75            System.Diagnostics.Debug.WriteLine("1. Wartosc ordernumber jest za duza.");
76            System.Diagnostics.Debug.WriteLine("2. Contetnt: " + result.Content);
77            Assert.That(result.Content.Contains("OverflowException"));
78        }
79        [Test]
80        [Category("Unit")]
81        public void IncorrectLength_Validationcode_Test()
82        {
83            var controller = new PlatnoscController();
84            var builder = new TestControllerBuilder();
85            builder.InitializeController(controller);
86            builder.Form.Add("MERCHANTNUMBER", "132");
87            builder.Form.Add("ORDERNUMBER", "1234");
88            builder.Form.Add("VALIDATIONCODE", "AAAaaa");
89           
90            var result = controller.Status() as ContentResult;
91            System.Diagnostics.Debug.WriteLine("1. Validationcode jest zbyt dlugi. Conajwyzej 3 znaki.");
92            System.Diagnostics.Debug.WriteLine("2. Contetnt: " + result.Content);
93            Assert.That(result.Content.Contains("SqlException"));
94        }
95    }
96}
Notatka: Zobacz TracBrowser aby uzyskać więcej informacji.