Index: trunk/eCard/eCardMVC/Platnosci.Core/Platnosci.Core.csproj
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Core/Platnosci.Core.csproj (revision 870)
+++ trunk/eCard/eCardMVC/Platnosci.Core/Platnosci.Core.csproj (revision 871)
@@ -33,4 +33,8 @@
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Elmah, Version=1.1.11517.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\..\Documents and Settings\Administrator\Pulpit\bin\net-3.5\Debug\Elmah.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Data" />
@@ -65,8 +69,6 @@
     <Compile Include="Interface\IDataContext.cs" />
     <Compile Include="Interface\IIdentifiable.cs" />
-    <Compile Include="Interface\IRep.cs" />
     <Compile Include="Interface\IRepository.cs" />
     <Compile Include="Linq\DataContext1.cs" />
-    <Compile Include="Linq\FakeDataContext.cs" />
     <Compile Include="Linq\Payer.cs" />
     <Compile Include="Linq\Platnosci.cs">
@@ -81,5 +83,4 @@
     <Compile Include="Linq\PlatnosciEcard.cs" />
     <Compile Include="Linq\PotwierdzeniaEcard.cs" />
-    <Compile Include="Linq\Rep.cs" />
     <Compile Include="Linq\Repository.cs" />
     <Compile Include="Linq\vPlatnosciEcard.cs" />
Index: trunk/eCard/eCardMVC/Platnosci/Web.config
===================================================================
--- trunk/eCard/eCardMVC/Platnosci/Web.config (revision 867)
+++ trunk/eCard/eCardMVC/Platnosci/Web.config (revision 871)
@@ -24,13 +24,31 @@
 			</sectionGroup>
 		</sectionGroup>
-	</configSections>
+    <sectionGroup name="elmah">
+      <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
+      <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
+      <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
+      <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
+    </sectionGroup>
+  </configSections>
   <appSettings>
     <add key="StatusLink" value="http://pay.truck-expo.com/info.aspx"/>
     <add key="Css" value="truck"/>
     <add key="StatusLink" value="http://platnosci.admoto.pl/info.aspx"/>
-    <add key="Css" value="admoto"/>
-    
+    <add key="Css" value="admoto"/>    
   </appSettings>
-	<connectionStrings>
+  <elmah>
+    <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
+    <security allowRemoteAccess="0" />
+  </elmah>
+  <!--
+  <location path="elmah.axd">
+    <system.web>
+      <authorization>
+        <deny users="?" />
+      </authorization>
+    </system.web>
+  </location>
+  -->
+  <connectionStrings>
 		<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
     <add name="Platnosci.Core.Properties.Settings.BAZA_REKLAM_TESTConnectionString" connectionString="Data Source=sql.ct.com.pl;Initial Catalog=BAZA_REKLAM_TEST;Persist Security Info=True;User ID=wwwadmin;Password=adm1648" providerName="System.Data.SqlClient"/>
@@ -115,9 +133,11 @@
 			<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
 			<add verb="*" path="*.mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
-		</httpHandlers>
+      <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
+    </httpHandlers>
 		<httpModules>
 			<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
 			<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
-		</httpModules>
+      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
+    </httpModules>
 	</system.web>
 	<system.codedom>
Index: trunk/eCard/eCardMVC/Platnosci/Models/FunkcjePlatnosci.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci/Models/FunkcjePlatnosci.cs (revision 866)
+++ trunk/eCard/eCardMVC/Platnosci/Models/FunkcjePlatnosci.cs (revision 871)
@@ -8,4 +8,5 @@
 using System.Web.Mvc;
 using System.Configuration;
+using System.Security.Principal;
 
 
@@ -91,4 +92,9 @@
             return str;
         }
+        public void SetUserLogger(string nip, string faktura){
+            
+            string User = nip + "-" + faktura;
+            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(User, ""), null);
+        }
         
     }
Index: trunk/eCard/eCardMVC/Platnosci/Views/Account/LogOn.aspx
===================================================================
--- trunk/eCard/eCardMVC/Platnosci/Views/Account/LogOn.aspx (revision 866)
+++ trunk/eCard/eCardMVC/Platnosci/Views/Account/LogOn.aspx (revision 871)
@@ -24,24 +24,24 @@
             <tr>
                 <td>
-                    <asp:Label ID="info" Text="<%$ Resources:tlumaczenia,info %>" runat="server"></asp:Label>
+                    <asp:Label ID="info" Text="<%$Resources:tlumaczenia,info %>" runat="server"></asp:Label>
                     <br /><br /> 
                 </td>
             </tr>                        
             <tr>
-                <td class="label_w"><asp:Label ID="nip" Text="<%$ Resources:tlumaczenia,Nip %>" runat="server"></asp:Label></td>
+                <td class="label_w"><asp:Label ID="nip" Text="<%$Resources:tlumaczenia,Nip %>" runat="server"></asp:Label></td>
             </tr>
             <tr>    
                 <td>
                     <%= Html.TextBox("nip")%>
-                    <%= Html.ValidationMessage("nip")%>
+                    <%= Html.ValidationMessage("nip","*")%>
                 </td>
             </tr>
             <tr>
-                <td class="label_w"><asp:Label ID="numerfaktury" Text="<%$ Resources:tlumaczenia,NumerFaktury %>" runat="server"></asp:Label></td>
+                <td class="label_w"><asp:Label ID="numerfaktury" Text="<%$Resources:tlumaczenia,NumerFaktury %>" runat="server"></asp:Label></td>
             </tr>
             <tr>    
                 <td>
                     <%= Html.TextBox("numer_faktury")%>
-                    <%= Html.ValidationMessage("numer_faktury")%>
+                    <%= Html.ValidationMessage("numer_faktury","*")%>
                 </td>
             </tr>
@@ -49,5 +49,5 @@
                 <td>
                     <br />
-                    <input id="but" type="submit" value="<%$Resources:tlumaczenia,Zaloguj%>" runat="server"></input>
+                    <input id="but" name="id" type="submit" value="<%=HttpContext.GetGlobalResourceObject("tlumaczenia","Zaloguj").ToString()%>"/>
                 </td>
             </tr>                                
Index: trunk/eCard/eCardMVC/Platnosci/Global.asax.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci/Global.asax.cs (revision 866)
+++ trunk/eCard/eCardMVC/Platnosci/Global.asax.cs (revision 871)
@@ -17,4 +17,5 @@
         public static void RegisterRoutes(RouteCollection routes)
         {
+            routes.IgnoreRoute("elmah.axd");
             routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
 
Index: trunk/eCard/eCardMVC/Platnosci/Controllers/AccountController.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci/Controllers/AccountController.cs (revision 870)
+++ trunk/eCard/eCardMVC/Platnosci/Controllers/AccountController.cs (revision 871)
@@ -66,5 +66,4 @@
             {
                 var Login = _repository.FindInvoiceByNipNumber(nip, numer_faktury).SingleOrDefault();
-                    //_context.FindInvoiceByNipNumber(nip, numer_faktury).SingleOrDefault();
                 platnosc = Login;
                 if (platnosc == null) return View();
@@ -78,4 +77,5 @@
             else
             {
+               _func.SetUserLogger(nip, numer_faktury);
                return RedirectToAction("Show", "Platnosc", new { id = platnosc.ID_faktury});
             }
Index: trunk/eCard/eCardMVC/Platnosci/Controllers/PlatnoscController.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci/Controllers/PlatnoscController.cs (revision 870)
+++ trunk/eCard/eCardMVC/Platnosci/Controllers/PlatnoscController.cs (revision 871)
@@ -23,17 +23,38 @@
         private readonly IDataContext _context1;
         private readonly IRepository<PotwierdzeniaEcard> _rep;
-        private readonly IRep<PotwierdzeniaEcard> _repository;
+        private readonly IRepository<PlatnosciEcard> _repPl;
         private FunkcjePlatnosci _func;
-
+        private string userIdentity = "";
+        private string weryfikacja = "";
+        private string brakdanych = "";
+        private string zaplacono = "";
+        private string err_imie = "";
+        private string err_nazwisko = "";
+        
+
+        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
+        {            
+            base.Initialize(requestContext);
+            userIdentity = HttpContext.User.Identity.Name;
+            weryfikacja = HttpContext.GetGlobalResourceObject("tlumaczenia", "weryfikacja").ToString();
+            brakdanych = HttpContext.GetGlobalResourceObject("tlumaczenia", "brakdanych").ToString();
+            zaplacono = HttpContext.GetGlobalResourceObject("tlumaczenia", "zaplacono").ToString();
+            err_imie = HttpContext.GetGlobalResourceObject("tlumaczenia", "err_imieWK").ToString();
+            err_nazwisko = HttpContext.GetGlobalResourceObject("tlumaczenia", "err_nazwiskoWK").ToString();           
+        }       
 
         public PlatnoscController()
         {
             _context = new PlatnosciDataContext();
-            _rep = new Repository<PotwierdzeniaEcard>(new DataContext1()); 
+            _rep = new Repository<PotwierdzeniaEcard>(new DataContext1());
+            _repPl = new Repository<PlatnosciEcard>(new DataContext1());
             _func = new FunkcjePlatnosci();
+                      
         }
         public PlatnoscController(IDataContext datacontext){
             _rep = new Repository<PotwierdzeniaEcard>(datacontext);
+            _repPl = new Repository<PlatnosciEcard>(datacontext);
             _context1 = datacontext;
+            _func = new FunkcjePlatnosci();            
         }
         public ActionResult Show(string id, string language)
@@ -49,16 +70,15 @@
             {
             }
-           
+          
             vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault();
-            //sprawdzamy czy numer faktury dotyczy zalogowanego usera
             ErrorViewData errorViewData = new ErrorViewData();
             if (platnosc == null)
             {
-               errorViewData.error = HttpContext.GetGlobalResourceObject("tlumaczenia", "brakdanych").ToString();
+               errorViewData.error = brakdanych;
                return View("Error1", errorViewData);                
             }
-            else if (!_func.UserIdentity(platnosc, ControllerContext.HttpContext.User.Identity.Name))
-            {
-                errorViewData.error = HttpContext.GetGlobalResourceObject("tlumaczenia", "weryfikacja").ToString();
+            else if (!_func.UserIdentity(platnosc, userIdentity))
+            {
+                errorViewData.error = weryfikacja;
                 return View("Error1", errorViewData);
             }
@@ -68,5 +88,5 @@
             {
                 string data_zaplaty = String.Format("{0:dd-MM-yyyy}",tablica_potwierdzenia[0].AUTHTIME);
-                errorViewData.error = String.Format(HttpContext.GetGlobalResourceObject("tlumaczenia", "zaplacono").ToString(), platnosc.Faktura_Numer, data_zaplaty);
+                errorViewData.error = String.Format(zaplacono, platnosc.Faktura_Numer, data_zaplaty);
                 return View("Error1", errorViewData);
             }
@@ -83,5 +103,4 @@
         {
             language = _func.setLanguage(language);
-            string userName = ControllerContext.HttpContext.User.Identity.Name;
             int id1 = 0;
             try
@@ -94,12 +113,18 @@
             vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault();
             ErrorViewData errorViewData = new ErrorViewData();
+
+            if (!_func.UserIdentity(platnosc, userIdentity))
+            {
+                errorViewData.error = weryfikacja;
+                return View("Error1", errorViewData);
+            }
             if (platnosc == null)
             {
-                errorViewData.error = HttpContext.GetGlobalResourceObject("tlumaczenia", "brakdanych").ToString();
-                return View("Error1", errorViewData);
-            }
-            else if (!_func.UserIdentity(platnosc, ControllerContext.HttpContext.User.Identity.Name))
-            {
-                errorViewData.error = HttpContext.GetGlobalResourceObject("tlumaczenia", "weryfikacja").ToString();
+                errorViewData.error = brakdanych;
+                return View("Error1", errorViewData);
+            }
+            else if (!_func.UserIdentity(platnosc, userIdentity))
+            {
+                errorViewData.error = weryfikacja;
                 return View("Error1", errorViewData);  
             }
@@ -107,11 +132,9 @@
             if (String.IsNullOrEmpty(payer.FirstName))
             {
-                string err_imieWK = HttpContext.GetGlobalResourceObject("tlumaczenia", "err_imieWK").ToString();
-                ModelState.AddModelError("Payer.FirstName", err_imieWK);
+                ModelState.AddModelError("Payer.FirstName", err_imie);
             }
             if (String.IsNullOrEmpty(payer.LastName))
             {
-                string err_nazwiskoWK = HttpContext.GetGlobalResourceObject("tlumaczenia", "err_nazwiskoWK").ToString();
-                ModelState.AddModelError("Payer.LastName", err_nazwiskoWK);
+                ModelState.AddModelError("Payer.LastName", err_nazwisko);
             }
             if (ModelState.IsValid == false)
@@ -146,7 +169,7 @@
                 return View("Error1", errorViewData);
             }
-            else if (!_func.UserIdentity(platnosc, ControllerContext.HttpContext.User.Identity.Name))
-            {
-                errorViewData.error = HttpContext.GetGlobalResourceObject("tlumaczenia", "weryfikacja").ToString();
+            else if (!_func.UserIdentity(platnosc, userIdentity))
+            {
+                errorViewData.error = weryfikacja;
                 return View("Error1", errorViewData);
             }
@@ -154,4 +177,15 @@
             return View(invoiceDeatailsViewData);
         }
+        public void UpdateStatus(int ordernumber, string validationcode)
+        {
+
+            var platnosc = _repPl.FindOne(i => i.ORDERNUMBER == ordernumber);
+            if (platnosc != null && platnosc.Status == true && validationcode == "000")
+            {
+                platnosc.Status = true;
+                platnosc.Status_data = DateTime.Now;
+                _repPl.Update(platnosc);
+            }
+        }
         public ActionResult Status()
         {
@@ -160,5 +194,4 @@
 
             //TODO: validate the Form
-
             string MERCHANTNUMBER = Request.Form["MERCHANTNUMBER"];
             int ORDERNUMBER = Convert.ToInt32(Request.Form["ORDERNUMBER"]);
@@ -214,4 +247,24 @@
             return invoiceDeatailsViewData;
         }
+        public void setUserIdentity(string value)
+        {
+            this.userIdentity = value;
+
+        }
+        public void setWeryfikacja(string value)
+        {
+            this.weryfikacja = value;
+
+        }
+        public void setBrakDanych(string value)
+        {
+            this.brakdanych = value;
+
+        }
+        public void setZaplacono(string value)
+        {
+            this.zaplacono = value;
+
+        }        
                
     }
Index: trunk/eCard/eCardMVC/Platnosci.Tests/Platnosci.Tests.csproj
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Tests/Platnosci.Tests.csproj (revision 866)
+++ trunk/eCard/eCardMVC/Platnosci.Tests/Platnosci.Tests.csproj (revision 871)
@@ -65,7 +65,12 @@
     <Reference Include="System.Data" />
     <Reference Include="System.Xml" />
+    <Reference Include="WatiN.Core, Version=2.0.10.928, Culture=neutral, PublicKeyToken=db7cfd3acb5ad44e, processorArchitecture=x86">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\..\Documents and Settings\Administrator\Pulpit\WatiN-2.0.10.928-net-2.0\bin\WatiN.Core.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Web\FakeDataContext.cs" />
     <Compile Include="Web\PlatnosciControllerTests.cs" />
   </ItemGroup>
@@ -80,4 +85,7 @@
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="app.config" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
Index: trunk/eCard/eCardMVC/Platnosci.Tests/Web/PlatnosciControllerTests.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Tests/Web/PlatnosciControllerTests.cs (revision 870)
+++ trunk/eCard/eCardMVC/Platnosci.Tests/Web/PlatnosciControllerTests.cs (revision 871)
@@ -11,11 +11,17 @@
 using Platnosci.Core.Interface;
 using Platnosci.Core.Linq;
+using WatiN.Core;
+using System.Threading;
+using Platnosci.Models;
+using Rhino.Mocks;
 
 namespace Platnosci.Tests.Web
 {
     [TestFixture]
+   
     class PlatnosciControllerTests
     {
-         private string merchantNumber = "123";
+        private string merchantNumber = "123";
+        private FunkcjePlatnosci _func = new FunkcjePlatnosci();
 
          /*[TearDown]
@@ -31,25 +37,80 @@
          }
         */
-         [Test]
-         public void Status_Saves_Correct_Transaction()
-         {
-            
-             var orderNumber = 9999;
-             FakeDataContext fake = new FakeDataContext();
-             var builder = new TestControllerBuilder();
-             var controller = new PlatnoscController(fake);
-             builder.InitializeController(controller);
-             builder.Form.Add("MERCHANTNUMBER", merchantNumber.ToString());
-             builder.Form.Add("AUTHTIME", DateTime.Now.ToString());
-             builder.Form.Add("DATATRANSMISJI", DateTime.Now.ToString());
-             builder.Form.Add("ORDERNUMBER", orderNumber.ToString());
-
-             var result = controller.Status();
-
-             IRepository<PotwierdzeniaEcard> _rep = new Repository<PotwierdzeniaEcard>(fake);            
-             var potwierdzeniaEcard = _rep.Find(p => p.ORDERNUMBER == orderNumber).First();
-             Assert.That(potwierdzeniaEcard.MERCHANTNUMBER, Is.EqualTo(merchantNumber));            
-         } 
-        [Test]
+       
+
+        [Test]
+        [Category("Unit")]
+        public void Status_Saves_Correct_Transaction()
+        {          
+            var orderNumber = 9999;
+            FakeDataContext fake = new FakeDataContext();
+            var builder = new TestControllerBuilder();
+            var controller = new PlatnoscController(fake);
+            builder.InitializeController(controller);
+            builder.Form.Add("MERCHANTNUMBER", merchantNumber.ToString());
+            builder.Form.Add("AUTHTIME", DateTime.Now.ToString());
+            builder.Form.Add("DATATRANSMISJI", DateTime.Now.ToString());
+            builder.Form.Add("ORDERNUMBER", orderNumber.ToString());
+
+            var result = controller.Status();
+
+            IRepository<PotwierdzeniaEcard> _rep = new Repository<PotwierdzeniaEcard>(fake);            
+            var potwierdzeniaEcard = _rep.Find(p => p.ORDERNUMBER == orderNumber).First();
+            Assert.That(potwierdzeniaEcard.MERCHANTNUMBER, Is.EqualTo(merchantNumber));            
+        }
+        [Test]
+        [Category("Unit")]
+        public void StatusIsUpdated()
+        {
+            FakeDataContext fake = new FakeDataContext();
+            IRepository<PlatnosciEcard> _rep = new Repository<PlatnosciEcard>(fake);
+             
+            DateTime data = DateTime.Now;
+
+            PlatnosciEcard platnosc = new PlatnosciEcard();
+            platnosc.ORDERNUMBER = 1;
+            platnosc.Status = true;
+            platnosc.Status_data = data;
+            _rep.Insert(platnosc);
+
+            var builder = new TestControllerBuilder();
+            var controller = new PlatnoscController(fake);
+            builder.InitializeController(controller);         
+
+            controller.UpdateStatus(1, "000");   //000 - płatność poprawna
+
+            PlatnosciEcard payment_after_update = new PlatnosciEcard();
+            payment_after_update = _rep.FindOne(i => i.ORDERNUMBER == 1);
+            Assert.That(payment_after_update.Status_data, Is.GreaterThan(data));
+        }
+        [Test]
+        [Category("Unit")]
+        public void StatusIsNotUpdated()
+        {
+            FakeDataContext fake = new FakeDataContext();
+            IRepository<PlatnosciEcard> _rep = new Repository<PlatnosciEcard>(fake);
+
+            DateTime data = DateTime.Now;
+
+            PlatnosciEcard platnosc = new PlatnosciEcard();
+            platnosc.ORDERNUMBER = 1;
+            platnosc.Status = true;
+            platnosc.Status_data = data;
+            _rep.Insert(platnosc);
+
+            var builder = new TestControllerBuilder();
+            var controller = new PlatnoscController(fake);
+            builder.InitializeController(controller);
+
+            controller.UpdateStatus(1, "111");   //111 - płatność niepoprawna, ze wzgledu na zly numer karty
+
+            PlatnosciEcard payment_after_update = new PlatnosciEcard();
+            payment_after_update = _rep.FindOne(i => i.ORDERNUMBER == 1);
+            Assert.That(payment_after_update.Status_data, Is.EqualTo(data));
+
+        }
+        
+        [Test]
+        [Category("Unit")]
         public void NumerFaktury()
         {
@@ -59,7 +120,8 @@
              vPlatnosciEcard platnosc = new vPlatnosciEcard();
              platnosc = _rep.FindInvoiceById(1).SingleOrDefault();
-             Assert.That(platnosc.Faktura_Numer, Is.EqualTo("222/2"));
-        }
-        [Test]
+             Assert.That(platnosc.Faktura_Numer, Is.EqualTo("1"));
+        }
+        [Test]
+        [Category("Unit")]
         public void AddPayment()
         {
@@ -80,5 +142,158 @@
             Assert.That(pl.nip, Is.EqualTo("nipek"));
         }
-        
+        [Test]
+        [Category("Unit")]
+        public void ShowPayment_BadNip()
+        {
+            FakeDataContext fake = new FakeDataContext();
+            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
+
+            vPlatnosciEcard platnosc = new vPlatnosciEcard();
+            platnosc.ID_faktury = 74828;
+            platnosc.nip = "854956281";
+            platnosc.Faktura_Numer = "27/ASZ/2009";
+            _rep.Insert(platnosc);
+
+            var builder = new TestControllerBuilder();
+            var controller = new PlatnoscController(fake);
+            controller.setUserIdentity("122");
+            controller.setWeryfikacja("Niepoprawny nip"); 
+            builder.InitializeController(controller);
+            
+            var result = controller.Show("74828","pl") as ViewResult;
+            var error = (ErrorViewData)result.ViewData.Model;
+            
+            Assert.That(error.error, Is.EqualTo("Niepoprawny nip"));          
+
+        }
+        [Test]
+        [Category("Unit")]
+        public void ShowPayment_CorrectData()
+        {
+            FakeDataContext fake = new FakeDataContext();
+            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
+
+            vPlatnosciEcard platnosc = new vPlatnosciEcard();
+            platnosc.ID_faktury = 74828;
+            platnosc.nip = "854956281";
+            platnosc.Faktura_Numer = "27/ASZ/2009";
+            platnosc.Brutto = 200;
+            _rep.Insert(platnosc);
+
+            var builder = new TestControllerBuilder();
+            var controller = new PlatnoscController(fake);
+            controller.setUserIdentity("854956281");
+            builder.InitializeController(controller);
+
+            var result = controller.Show("74828", "pl") as ViewResult;
+            var view = (InvoiceDetailsViewData)result.ViewData.Model;
+
+            Assert.That(view.vPlatnosciEcard.Brutto, Is.EqualTo(200));
+            Assert.That(view.vPlatnosciEcard.Faktura_Numer, Is.EqualTo("27/ASZ/2009"));
+
+        }
+        [Test]
+        [Category("Unit")]
+        public void PaymentIsNotValid()
+        {
+            FakeDataContext fake = new FakeDataContext();
+            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
+
+            vPlatnosciEcard platnosc = new vPlatnosciEcard();
+            platnosc.ID_faktury = 74828;
+            platnosc.nip = "854956281";
+            platnosc.Faktura_Numer = "27/ASZ/2009";
+            platnosc.Brutto = 200;
+            platnosc.SystemKsiegowyId = 2;
+            _rep.Insert(platnosc);
+
+            var builder = new TestControllerBuilder();
+            var controller = new PlatnoscController(fake);
+            controller.setUserIdentity("854956281");
+            builder.InitializeController(controller);
+
+            Payer payer = new Payer();
+            payer.Id_faktury = 74828;
+            payer.LastName = "test";  //Nie wprowadzono imienia
+
+            controller.Show(payer, "pl");
+            Assert.That(controller.ModelState.IsValid, Is.False);
+        }
+        [Test]
+        [Category("Unit")]
+        public void PaymentIsValid()
+        {
+            FakeDataContext fake = new FakeDataContext();
+            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
+
+            vPlatnosciEcard platnosc = new vPlatnosciEcard();
+            platnosc.ID_faktury = 74828;
+            platnosc.nip = "854956281";
+            platnosc.Faktura_Numer = "27/ASZ/2009";
+            platnosc.Brutto = 200;
+            platnosc.SystemKsiegowyId = 2;
+            _rep.Insert(platnosc);
+
+            var builder = new TestControllerBuilder();
+            var controller = new PlatnoscController(fake);
+            controller.setUserIdentity("854956281");
+            builder.InitializeController(controller);
+
+            Payer payer = new Payer();
+            payer.Id_faktury = 74828;
+            payer.LastName = "test";
+            payer.FirstName = "test";
+
+            controller.Show(payer, "pl");
+            Assert.That(controller.ModelState.IsValid, Is.True); 
+        }
+        [Test]
+        [Category("Unit")]
+        public void ShowPayment_BadId()
+        {
+            FakeDataContext fake = new FakeDataContext();
+            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
+
+            vPlatnosciEcard platnosc = new vPlatnosciEcard();
+            platnosc.ID_faktury = 74828;
+            platnosc.nip = "854956281";
+            platnosc.Faktura_Numer = "27/ASZ/2009";
+            _rep.Insert(platnosc);
+
+            var builder = new TestControllerBuilder();
+            var controller = new PlatnoscController(fake);
+            controller.setUserIdentity("1");
+            controller.setWeryfikacja("Nie ma takiej platnosci.");
+            builder.InitializeController(controller);
+
+            var result = controller.Show("1", "pl") as ViewResult;
+            var error = (ErrorViewData)result.ViewData.Model;
+
+            Assert.That(error.error, Is.EqualTo("Nie ma takiej platnosci."));
+
+        }
+        [Test]
+        [Category("UI")]
+        public void checkLoginCorrect()
+        {
+            IE ie = new IE("http://localhost:3646/pl/Account/LogOn");
+            ie.TextField(Find.ByName("numer_faktury")).TypeText("24/HOL/2009");
+            ie.TextField(Find.ByName("nip")).TypeText("501379568");
+            ie.Button(Find.ById("but")).Click();
+
+            Assert.IsTrue(ie.ContainsText("została uregulowana"));
+        }
+        [Test]
+        [Category("UI")]
+        public void checkErrorLogin()
+        {
+            IE ie = new IE("http://localhost:3646/pl/Account/LogOn");
+            ie.TextField(Find.ByName("numer_faktury")).TypeText("");
+            ie.TextField(Find.ByName("nip")).TypeText("");
+            ie.Button(Find.ById("but")).Click();
+
+            Assert.IsTrue(ie.ContainsText("Logowanie nie powiodło się"));
+        }
+      
     }
 }
