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

Wersja 913, 5.7 KB (wprowadzona przez alina, 16 years temu)

re #215 testowanie akcji status na prawdziwej a nie fake'owej bazie

Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using NUnit.Framework;
6using Platnosci.Core.Linq;
7using Platnosci.Core.Interface;
8using MvcContrib.TestHelper;
9using Platnosci.Controllers;
10using System.Web.Mvc;
11
12namespace Platnosci.Tests.Web
13{
14    [TestFixture]
15    class StatusTest
16    {
17        private Function _f = new Function();
18
19        [Test]
20        [Category("Unit")]
21        public void FormatException_Ordernumber_Test()
22        {
23            IRepository<PotwierdzeniaEcard> repConfirm = new Repository<PotwierdzeniaEcard>(new FakeDataContext());
24            var builder = new TestControllerBuilder();
25            var controller = new PlatnoscController(null, null, repConfirm, null);
26            builder.InitializeController(controller);
27            builder.Form.Add("MERCHANTNUMBER", "132423");
28            builder.Form.Add("ORDERNUMBER", "32hvhsvhv");
29
30            var result = controller.Status() as ContentResult;           
31            System.Diagnostics.Debug.WriteLine("1. Zły formt ordernumber.");
32            System.Diagnostics.Debug.WriteLine("2. Count: " + repConfirm.Count());
33            System.Diagnostics.Debug.WriteLine("3. Contetnt: " + result.Content);
34            Assert.That(repConfirm.Count().Equals(0));
35            Assert.That(result.Content.Contains("FormatException"));
36        }
37        [Test]
38        [Category("Unit")]
39        public void FormatException_Paymenttype_Test()
40        {
41            IRepository<PotwierdzeniaEcard> repConfirm = new Repository<PotwierdzeniaEcard>(new FakeDataContext());
42            var builder = new TestControllerBuilder();
43            var controller = new PlatnoscController(null, null, repConfirm, null);
44            builder.InitializeController(controller);
45            builder.Form.Add("MERCHANTNUMBER", "132423");
46            builder.Form.Add("PAYMENTTYPE", "32hvhsvhv");
47
48            var result = controller.Status() as ContentResult;
49            System.Diagnostics.Debug.WriteLine("Zły formt paymenttype. " + " Count: " + repConfirm.Count());
50            Assert.That(repConfirm.Count().Equals(0));
51            Assert.That(result.Content.Contains("FormatException"));
52        }
53        [Test]
54        [Category("Unit")]
55        public void FormatException_Eventtype_Test()
56        {
57            IRepository<PotwierdzeniaEcard> repConfirm = new Repository<PotwierdzeniaEcard>(new FakeDataContext());
58            var builder = new TestControllerBuilder();
59            var controller = new PlatnoscController(null, null, repConfirm, null);
60            builder.InitializeController(controller);
61            builder.Form.Add("MERCHANTNUMBER", "132423");
62            builder.Form.Add("EVENTTYPE", "32hvhsvhv");
63
64            var result = controller.Status() as ContentResult;
65            System.Diagnostics.Debug.WriteLine("Zły formt eventtype. " + " Count: " + repConfirm.Count());
66            Assert.That(repConfirm.Count().Equals(0));
67            Assert.That(result.Content.Contains("FormatException"));
68        }
69        [Test]
70        [Category("Unit")]
71        public void OverflowException_Ordernumber_Test()
72        {
73            var controller = new PlatnoscController();
74            var builder = new TestControllerBuilder();
75            builder.InitializeController(controller);
76            builder.Form.Add("MERCHANTNUMBER", "132");
77            builder.Form.Add("ORDERNUMBER", "12311111111111111");
78            builder.Form.Add("VALIDATIONCODE", "AAA");
79           
80            var result = controller.Status() as ContentResult;
81            System.Diagnostics.Debug.WriteLine("1. Wartosc ordernumber jest za duza.");
82            System.Diagnostics.Debug.WriteLine("2. Contetnt: " + result.Content);
83            Assert.That(result.Content.Contains("OverflowException"));
84        }
85        [Test]
86        [Category("Unit")]
87        public void IncorrectLength_Validationcode_Test()
88        {
89            var controller = new PlatnoscController();
90            var builder = new TestControllerBuilder();
91            builder.InitializeController(controller);
92            builder.Form.Add("MERCHANTNUMBER", "132");
93            builder.Form.Add("ORDERNUMBER", "1234");
94            builder.Form.Add("VALIDATIONCODE", "AAAaaa");
95           
96            var result = controller.Status() as ContentResult;
97            System.Diagnostics.Debug.WriteLine("1. Validationcode jest zbyt dlugi. Conajwyzej 3 znaki.");
98            System.Diagnostics.Debug.WriteLine("2. Contetnt: " + result.Content);
99            Assert.That(result.Content.Contains("SqlException"));
100        }
101        [Test]
102        [Category("Unit")]
103        public void Correct_Date_Test()
104        {
105            string merchant = "ABC15S";
106            int order = 1234;
107
108            var controller = new PlatnoscController();
109            IRepository<PotwierdzeniaEcard> repConfirm = controller.getRepConfirm();
110            var builder = new TestControllerBuilder();
111            builder.InitializeController(controller);
112            builder.Form.Add("MERCHANTNUMBER", merchant);
113            builder.Form.Add("ORDERNUMBER", order.ToString());
114            builder.Form.Add("VALIDATIONCODE", "000");
115
116            var result = controller.Status();
117            var pl = repConfirm.Find(o => o.MERCHANTNUMBER == merchant && o.ORDERNUMBER == order).SingleOrDefault();
118            System.Diagnostics.Debug.WriteLine("Dodano płatność do repozytorium.");
119            Assert.That(pl.ORDERNUMBER.Equals(order));
120           
121            repConfirm.Delete(pl);
122            System.Diagnostics.Debug.WriteLine("Usunięto poprawnie płatność o ORDERNUMBER: " + pl.ORDERNUMBER +" i MERCHANTNUMBER: " + pl.MERCHANTNUMBER);
123        }
124    }
125}
Notatka: Zobacz TracBrowser aby uzyskać więcej informacji.