Index: trunk/eCard/eCardMVC/adMoto.Payments.Test/Controllers/eCardControllerTests.cs
===================================================================
--- trunk/eCard/eCardMVC/adMoto.Payments.Test/Web/StatusTest.cs (revision 971)
+++ trunk/eCard/eCardMVC/adMoto.Payments.Test/Controllers/eCardControllerTests.cs (revision 982)
@@ -1,96 +1,150 @@
-﻿using adMoto.Payments.Core;
+﻿using System;
+using System.Collections.Specialized;
+using System.Linq;
+using adMoto.Payments.Core;
 using adMoto.Payments.Core.Data;
 using adMoto.Payments.Core.Interfaces;
+using adMoto.Payments.Test.Fakes;
+using adMoto.Payments.Web.Controllers;
 using NUnit.Framework;
 using MvcContrib.TestHelper;
 using System.Web.Mvc;
 
-namespace adMoto.Payments.Test.Web
+namespace adMoto.Payments.Test.Controllers
 {
     [TestFixture]
-    public class StatusTest
+// ReSharper disable InconsistentNaming
+    public class eCardControllerTests
+// ReSharper restore InconsistentNaming
     {
-        //[Test]
-        //[Category("Unit")]
-        //public void FormatException_Ordernumber_Test()
-        //{
-        //    IRepository<PotwierdzeniaEcard> repConfirm = new Repository<PotwierdzeniaEcard>(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");
+        private IRepository<PotwierdzeniaEcard> _repConfirm;
 
-        //    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<PotwierdzeniaEcard> repConfirm = new Repository<PotwierdzeniaEcard>(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");
+        private eCardController CreateController()
+        {
+            _repConfirm = new Repository<PotwierdzeniaEcard>(new FakeDataContext());
 
-        //    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<PotwierdzeniaEcard> repConfirm = new Repository<PotwierdzeniaEcard>(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 builder = new TestControllerBuilder();
+            return builder.CreateController<eCardController>(_repConfirm);
+        }
 
-        //    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");
+        [Test]
+        [Category("Unit")]
+        public void  Status_Returns_True_When_Passing_Correct_Request_Data()
+        {
+            var controller = CreateController();
+            const string dateFormat = "yyyy-MM-dd HH:mm:ss.fff";
+            var dateTime = DateTime.Now.ToString(dateFormat);
+            var formValues = new NameValueCollection {
+                                                         {"MERCHANTNUMBER", "1"}, 
+                                                         {"ORDERNUMBER", "2"},
+                                                         {"COMMTYPE", "3"},
+                                                         {"CURRENTSTATE", "4"},
+                                                         {"PREVIOUSSTATE", "5"},
+                                                         {"PAYMENTTYPE", "1"},
+                                                         {"EVENTTYPE", "0"},
+                                                         {"PAYMENTNUMBER", "1"},
+                                                         {"APPROVALCODE", "6"},
+                                                         {"VALIDATIONCODE", "7"},
+                                                         {"BIN", "8"},
+                                                         {"AUTHTIME", dateTime},
+                                                         {"TYPE", "9"},
+                                                         {"WITHCVC", "10"}};
+            controller.Request.Form.Add(formValues);
+
+            var result = controller.Status() as ContentResult;
+
+            Assert.That(result.Content.Contains("OK"));
             
-        //    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"));
-        //}
+            var paymentConfirmation = _repConfirm.FindAll().First();
+            Assert.That(paymentConfirmation.MERCHANTNUMBER, Is.EqualTo("1"));
+            Assert.That(paymentConfirmation.ORDERNUMBER, Is.EqualTo(2));
+            Assert.That(paymentConfirmation.COMMTYPE, Is.EqualTo("3"));
+            Assert.That(paymentConfirmation.CURRENTSTATE, Is.EqualTo("4"));
+            Assert.That(paymentConfirmation.PREVIOUSSTATE, Is.EqualTo("5"));
+            Assert.That(paymentConfirmation.APPROVALCODE, Is.EqualTo("6"));
+            Assert.That(paymentConfirmation.VALIDATIONCODE, Is.EqualTo("7"));
+            Assert.That(paymentConfirmation.BIN, Is.EqualTo("8"));
+            Assert.That(paymentConfirmation.TYPE, Is.EqualTo("9"));
+            Assert.That(paymentConfirmation.WITHCVC, Is.EqualTo("10"));
+            Assert.That(paymentConfirmation.PAYMENTTYPE, Is.True);
+            Assert.That(paymentConfirmation.EVENTTYPE, Is.False);
+            Assert.That(paymentConfirmation.PAYMENTNUMBER, Is.True);
+            Assert.That(paymentConfirmation.AUTHTIME.Value.ToString(dateFormat), Is.EqualTo(dateTime));
+        }
+
+        [Test]
+        [Category("Unit")]
+        public void Status_Returns_False_And_Throws_FormatException_When_Passing_OrderNumber_In_Wrong_Format()
+        {
+            var controller = CreateController();
+            var valueCollection = new NameValueCollection {{"ORDERNUMBER", "fdsf"}};
+            controller.Request.Form.Add(valueCollection);
+
+            var result = controller.Status() as ContentResult;
+
+            Assert.That(_repConfirm.Count(), Is.EqualTo(0));
+            Assert.That(result.Content.Contains("FALSE"));
+            Assert.That(result.Content.Contains("FormatException"));
+        }
+
+        [Test]
+        [Category("Unit")]
+        public void Status_Returns_False_And_Throws_FormatException_When_Passing_PaymentType_In_Wrong_Format()
+        {
+            var controller = CreateController();
+            var valueCollection = new NameValueCollection { { "PAYMENTTYPE", "32hvhsvhv" } };
+            controller.Request.Form.Add(valueCollection);
+
+            var result = controller.Status() as ContentResult;
+
+            Assert.That(_repConfirm.Count(), Is.EqualTo(0));
+            Assert.That(result.Content.Contains("FALSE"));
+            Assert.That(result.Content.Contains("FormatException"));
+        }
+
+        [Test]
+        [Category("Unit")]
+        public void Status_Returns_False_And_Throws_FormatException_When_Passing_EventType_In_Wrong_Format()
+        {
+            var controller = CreateController();
+            var valueCollection = new NameValueCollection { { "EVENTTYPE", "32hvhsvhv" } };
+            controller.Request.Form.Add(valueCollection);
+
+            var result = controller.Status() as ContentResult;
+
+            Assert.That(_repConfirm.Count(), Is.EqualTo(0));
+            Assert.That(result.Content.Contains("FALSE"));
+            Assert.That(result.Content.Contains("FormatException"));
+        }
+
+        [Test]
+        [Category("Unit")]
+        public void Status_Returns_False_And_Throws_OverflowException_When_Passing_OrderNumer_Greater_Than_Integer()
+        {
+            var controller = CreateController();
+            var valueCollection = new NameValueCollection { { "ORDERNUMBER", "12311111111111111" } };
+            controller.Request.Form.Add(valueCollection);
+
+            var result = controller.Status() as ContentResult;
+
+            Assert.That(_repConfirm.Count(), Is.EqualTo(0));
+            Assert.That(result.Content.Contains("FALSE"), "Response should contain FALSE");
+            Assert.That(result.Content.Contains("OverflowException"), "Response should contain OverflowException");
+        }
+
+        [Test]
+        [Category("Unit")]
+        public void Status_Returns_False_And_Throws_SqlException_When_Passing_ValidationCode_Longer_Than_Three_Characters()
+        {
+            var controller = CreateController();
+            var valueCollection = new NameValueCollection { { "VALIDATIONCODE", "1234" } };
+            controller.Request.Form.Add(valueCollection);
+
+            var result = controller.Status() as ContentResult;
+
+            Assert.That(_repConfirm.Count(), Is.EqualTo(0), "Should not have any items");
+            Assert.That(result.Content.Contains("FALSE"), "Response should contain FALSE");
+            Assert.That(result.Content.Contains("ArgumentException"), "Response should contain SqlException");
+        }
     }
 }
