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

Wersja 911, 4.6 KB (wprowadzona przez alina, 16 years temu)

re #215 dodano formularz dla potwierdzenia, dodano testy sprawdzajace typy i format zmiennych przesylanych z eCardu

RevLine 
[911]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       
102    }
103}
Notatka: Zobacz TracBrowser aby uzyskać więcej informacji.