Index: trunk/eCard/eCardMVC/Platnosci.Core/Interface/IDataContext.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Core/Interface/IDataContext.cs (revision 872)
+++ trunk/eCard/eCardMVC/Platnosci.Core/Interface/IDataContext.cs (revision 872)
@@ -0,0 +1,19 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using Platnosci.Core.Linq;
+using System.Text; 
+
+namespace Platnosci.Core.Interface
+{
+    public interface IDataContext
+    {
+        void SubmitChanges();
+        IQueryable<T> GetTable<T>() where T : class;
+        void Insert<T>(T item) where T : class;
+        IQueryable<vPlatnosciEcard> FindInvoiceByNipNumber(string nip, string numer);
+        IQueryable<vPlatnosciEcard> FindInvoiceById(int id);
+        List<PotwierdzeniaEcard> FindItemsByIdFaktury(int idFaktury);
+    }
+}
Index: trunk/eCard/eCardMVC/Platnosci.Core/Linq/DataContext1.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Core/Linq/DataContext1.cs (revision 872)
+++ trunk/eCard/eCardMVC/Platnosci.Core/Linq/DataContext1.cs (revision 872)
@@ -0,0 +1,83 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using Platnosci.Core.Interface;
+using System.Data.Linq;
+
+namespace Platnosci.Core.Linq
+{
+    public class DataContext1 : IDataContext
+	{
+	        private readonly PlatnosciDataContext _dataContext;
+            private List<object> listaPlatnosci = new List<object>();
+            public DataContext1()
+	        {
+	            _dataContext = new PlatnosciDataContext();
+	        }            
+	        public IQueryable<T> GetTable<T>() where T : class
+	        {
+	            return _dataContext.GetTable<T>();
+	        }
+            public void Insert<T>(T item) where T : class
+	        {
+	            _dataContext.GetTable<T>().InsertOnSubmit(item);
+                _dataContext.SubmitChanges();
+	        }
+            public void Delete<T>(T item) where T : class 
+            {
+                if (item != null)
+                {
+                    _dataContext.GetTable<T>().DeleteOnSubmit(item);
+                    _dataContext.SubmitChanges();
+                }
+            }
+            public void SubmitChanges()
+            {
+                _dataContext.SubmitChanges();
+            }
+            public IQueryable<vPlatnosciEcard> FindInvoiceByNipNumber(string nip, string numer)
+            {
+                var query = from i in _dataContext.vPlatnosciEcards
+                            where (i.nip == nip && i.Faktura_Numer == numer)
+                            select i;
+                return query;
+            }
+            public IQueryable<vPlatnosciEcard> FindInvoiceById(int id)
+            {
+                var query = from i in _dataContext.vPlatnosciEcards
+                            where i.ID_faktury == id
+                            select i;
+                return query;
+            }
+            public List<PotwierdzeniaEcard> FindItemsByIdFaktury(int idFaktury)
+            {
+                var query = from vp in _dataContext.PlatnosciEcards
+                            where vp.IDFaktury == idFaktury && vp.Status == true
+                            orderby vp.IDFaktury descending
+                            select vp;
+
+                query.ToList();
+                var tablica = new List<PotwierdzeniaEcard>();
+
+                foreach (var pt in query)
+                {
+                    var query2 = from ps in _dataContext.PotwierdzeniaEcards
+                                 where ps.ORDERNUMBER == pt.ORDERNUMBER && ps.VALIDATIONCODE == "000"
+                                 orderby ps.id
+                                 select ps;
+
+                    for (var i = 0; i < query2.ToList().Count; i++)
+                    {
+                        tablica.Add(query2.ToList()[i]);
+                    }
+                }
+                return tablica;
+            }
+            public List<object> getlista()
+            {
+                return listaPlatnosci;
+            }            
+
+    }
+}
Index: trunk/eCard/eCardMVC/Platnosci.Core/Linq/Repository.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Core/Linq/Repository.cs (revision 870)
+++ trunk/eCard/eCardMVC/Platnosci.Core/Linq/Repository.cs (revision 872)
@@ -17,6 +17,4 @@
     public class Repository<T> : IRepository<T> where T : class, IIdentifiable
     {
-       // private readonly PlatnosciDataContext _dataContext = new PlatnosciDataContext();
-        //private PlatnosciDataContext _dataContext = new PlatnosciDataContext();
         protected readonly IDataContext _dataContext;
 
Index: trunk/eCard/eCardMVC/Platnosci.Core/Linq/PotwierdzeniaEcard.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Core/Linq/PotwierdzeniaEcard.cs (revision 872)
+++ trunk/eCard/eCardMVC/Platnosci.Core/Linq/PotwierdzeniaEcard.cs (revision 872)
@@ -0,0 +1,19 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using Platnosci.Core.Interface;
+
+namespace Platnosci.Core.Linq
+{
+    public partial class PotwierdzeniaEcard : IIdentifiable
+    {
+        public int Id
+        {
+            get
+            {
+                return this.id;
+            }
+        }
+    }
+}
Index: trunk/eCard/eCardMVC/Platnosci/Controllers/PlatnoscController.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci/Controllers/PlatnoscController.cs (revision 871)
+++ trunk/eCard/eCardMVC/Platnosci/Controllers/PlatnoscController.cs (revision 872)
@@ -25,5 +25,4 @@
         private readonly IRepository<PlatnosciEcard> _repPl;
         private FunkcjePlatnosci _func;
-        private string userIdentity = "";
         private string weryfikacja = "";
         private string brakdanych = "";
@@ -31,10 +30,8 @@
         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();
@@ -52,14 +49,15 @@
                       
         }
-        public PlatnoscController(IDataContext datacontext){
+        public PlatnoscController(IDataContext datacontext)
+        {
             _rep = new Repository<PotwierdzeniaEcard>(datacontext);
             _repPl = new Repository<PlatnosciEcard>(datacontext);
             _context1 = datacontext;
-            _func = new FunkcjePlatnosci();            
+            _func = new FunkcjePlatnosci();
         }
         public ActionResult Show(string id, string language)
         {
+          
             language = _func.setLanguage(language);
-            string jezyk = Thread.CurrentThread.CurrentCulture.Name.ToString();
             int id1 = 0;
             try
@@ -69,6 +67,5 @@
             catch
             {
-            }
-          
+            }          
             vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault();
             ErrorViewData errorViewData = new ErrorViewData();
@@ -78,5 +75,5 @@
                return View("Error1", errorViewData);                
             }
-            else if (!_func.UserIdentity(platnosc, userIdentity))
+            else if (!_func.UserIdentity(platnosc, HttpContext.User.Identity.Name))
             {
                 errorViewData.error = weryfikacja;
@@ -90,6 +87,5 @@
                 errorViewData.error = String.Format(zaplacono, platnosc.Faktura_Numer, data_zaplaty);
                 return View("Error1", errorViewData);
-            }
-            
+            }            
             string kwota = "";
             kwota = _func.BruttoToString(platnosc.Brutto, platnosc.waluta_brutto, platnosc.waluta_miano);
@@ -114,5 +110,5 @@
             ErrorViewData errorViewData = new ErrorViewData();
 
-            if (!_func.UserIdentity(platnosc, userIdentity))
+            if (!_func.UserIdentity(platnosc, HttpContext.User.Identity.Name))
             {
                 errorViewData.error = weryfikacja;
@@ -124,5 +120,5 @@
                 return View("Error1", errorViewData);
             }
-            else if (!_func.UserIdentity(platnosc, userIdentity))
+            else if (!_func.UserIdentity(platnosc, HttpContext.User.Identity.Name))
             {
                 errorViewData.error = weryfikacja;
@@ -166,8 +162,8 @@
             if (platnosc == null)
             {
-                errorViewData.error = HttpContext.GetGlobalResourceObject("tlumaczenia", "faktura_error").ToString();
-                return View("Error1", errorViewData);
-            }
-            else if (!_func.UserIdentity(platnosc, userIdentity))
+                errorViewData.error = brakdanych;
+                return View("Error1", errorViewData);
+            }
+            else if (!_func.UserIdentity(platnosc, HttpContext.User.Identity.Name))
             {
                 errorViewData.error = weryfikacja;
@@ -247,9 +243,4 @@
             return invoiceDeatailsViewData;
         }
-        public void setUserIdentity(string value)
-        {
-            this.userIdentity = value;
-
-        }
         public void setWeryfikacja(string value)
         {
Index: trunk/eCard/eCardMVC/Platnosci.Tests/Platnosci.Tests.csproj
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Tests/Platnosci.Tests.csproj (revision 871)
+++ trunk/eCard/eCardMVC/Platnosci.Tests/Platnosci.Tests.csproj (revision 872)
@@ -32,4 +32,8 @@
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Moq, Version=4.0.812.4, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\..\Documents and Settings\Administrator\Pulpit\Moq.4.0.812.4-bin\Moq.dll</HintPath>
+    </Reference>
     <Reference Include="MvcContrib, Version=1.5.996.0, Culture=neutral, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
@@ -54,4 +58,7 @@
     <Reference Include="System" />
     <Reference Include="System.Core">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="System.Web.Abstractions">
       <RequiredTargetFramework>3.5</RequiredTargetFramework>
     </Reference>
Index: trunk/eCard/eCardMVC/Platnosci.Tests/Web/PlatnosciControllerTests.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Tests/Web/PlatnosciControllerTests.cs (revision 871)
+++ trunk/eCard/eCardMVC/Platnosci.Tests/Web/PlatnosciControllerTests.cs (revision 872)
@@ -14,5 +14,5 @@
 using System.Threading;
 using Platnosci.Models;
-using Rhino.Mocks;
+using Moq;
 
 namespace Platnosci.Tests.Web
@@ -37,6 +37,45 @@
          }
         */
-       
-
+
+        public vPlatnosciEcard createPayment(int id, string nip, string fak_numer, decimal brutto, byte SystemKsiegowy)
+        {
+
+            vPlatnosciEcard platnosc = new vPlatnosciEcard();
+            platnosc.ID_faktury = id;
+            platnosc.nip = nip;
+            platnosc.Faktura_Numer = fak_numer;
+            platnosc.Brutto = brutto;
+            platnosc.SystemKsiegowyId = SystemKsiegowy;
+
+            return platnosc;
+        }
+        public PlatnosciEcard createNewPayment(int ordernumber, bool status, DateTime data, int id_faktury)
+        {
+            PlatnosciEcard platnosc = new PlatnosciEcard();
+            platnosc.ORDERNUMBER = ordernumber;
+            platnosc.Status = status;
+            platnosc.Status_data = data;
+            platnosc.IDFaktury = id_faktury;
+
+            return platnosc;
+        }
+        public Payer createPayer(int id, string name, string surname)
+        {
+            Payer payer = new Payer();
+            payer.Id_faktury = id;
+            payer.FirstName = name;
+            payer.LastName = surname;
+
+            return payer;
+        }
+        public ControllerContext createControllerContext(string UserIdentity)
+        {
+
+            var mock = new Mock<ControllerContext>();
+            mock.SetupGet(m => m.HttpContext.User.Identity.Name).Returns(UserIdentity);
+            mock.SetupGet(m => m.HttpContext.Request.IsAuthenticated).Returns(true);
+
+            return mock.Object;
+        }
         [Test]
         [Category("Unit")]
@@ -65,17 +104,10 @@
             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);         
-
+            PlatnosciEcard platnosc = createNewPayment(1, true, data, 1);
+            _rep.Insert(platnosc);
+
+            var controller = new PlatnoscController(fake); 
             controller.UpdateStatus(1, "000");   //000 - płatność poprawna
 
@@ -93,14 +125,8 @@
             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);
-
+            PlatnosciEcard platnosc = createNewPayment(1, true, data, 1);
+            _rep.Insert(platnosc);
+
+            var controller = new PlatnoscController(fake);
             controller.UpdateStatus(1, "111");   //111 - płatność niepoprawna, ze wzgledu na zly numer karty
 
@@ -108,10 +134,8 @@
             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()
+        }        
+        [Test]
+        [Category("Unit")]
+        public void TestFindInvoiceByNumber()
         {
              FakeDataContext fake = new FakeDataContext();
@@ -124,17 +148,13 @@
         [Test]
         [Category("Unit")]
-        public void AddPayment()
-        {
-            FakeDataContext fake = new FakeDataContext();
-            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
-
-            vPlatnosciEcard platnosc = new vPlatnosciEcard();
-            platnosc.ID_faktury = 13;
-            platnosc.nip = "nipek";
-            _rep.Insert(platnosc);
-
-            vPlatnosciEcard pl1 = new vPlatnosciEcard();
-            pl1.ID_faktury = 14;
-            pl1.nip = "vv";
+        public void TestInsertMethodForPayment()
+        {
+            FakeDataContext fake = new FakeDataContext();
+            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
+
+            vPlatnosciEcard platnosc = createPayment(13, "nipek", "", 0, 0);
+            _rep.Insert(platnosc);
+
+            vPlatnosciEcard pl1 = createPayment(14, "vv", "", 0, 0);
             _rep.Insert(pl1);
 
@@ -144,133 +164,116 @@
         [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);
+        public void ActionShowPayment_IncorrectUserIdentity_ReturnErrorView()
+        {
+            FakeDataContext fake = new FakeDataContext();
+            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
+
+            vPlatnosciEcard platnosc = createPayment(74828, "854956281", "27/ASZ/2009", 0, 0);
+            _rep.Insert(platnosc);
+
+            var controller = new PlatnoscController(fake);
+            controller.ControllerContext = createControllerContext("1");
+            controller.setWeryfikacja("Niepoprawny nip");
             
+           
             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);
+            Assert.That(error.error, Is.EqualTo("Niepoprawny nip"));
+            Assert.That(result.ViewName, Is.EqualTo("Error1"));
+        }
+        [Test]
+        [Category("Unit")]
+        public void ActionShowPayment_PaymentNotFound_ReturnErrorView()
+        {
+            FakeDataContext fake = new FakeDataContext();
+            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
+
+            vPlatnosciEcard platnosc = createPayment(74828, "854956281", "27/ASZ/2009", 0,0);
+            _rep.Insert(platnosc);
+
+            var controller = new PlatnoscController(fake);
+
+            controller.ControllerContext = createControllerContext("854956281");
+            controller.setBrakDanych("Platnosc o takim id nie istnieje");
+
+            var result = controller.Show("123", "pl") as ViewResult;
+            var error = (ErrorViewData)result.ViewData.Model;
+
+            Assert.That(error.error, Is.EqualTo("Platnosc o takim id nie istnieje"));
+            Assert.That(result.ViewName, Is.EqualTo("Error1"));
+        }
+        [Test]
+        [Category("Unit")]
+        public void ActionShowPayment_PaymentIsPayed(){
+            //Tworzymy takie dane aby platnosc o danym id byla juz zaplacona 
+            FakeDataContext fake = new FakeDataContext(1); 
+            var controller = new PlatnoscController(fake);
+
+            controller.ControllerContext = createControllerContext("nip");
+            controller.setZaplacono("Platnosc zostala uregulowana");
+
+            var result = controller.Show("128", "pl") as ViewResult;
+            var error = (ErrorViewData)result.ViewData.Model;
+
+            Assert.That(result.ViewName, Is.EqualTo("Error1"));
+            Assert.That(error.error, Is.EqualTo("Platnosc zostala uregulowana"));
+        }
+        [Test]
+        [Category("Unit")]
+        public void ActionShowPayment_CorrectData_ReturnViewForPayment()
+        {
+            FakeDataContext fake = new FakeDataContext();
+            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
+                                                  
+            vPlatnosciEcard platnosc = createPayment(74828,"854956281","27/ASZ/2009",200,0);
+            _rep.Insert(platnosc);
+
+            var controller = new PlatnoscController(fake);
+            controller.ControllerContext = createControllerContext("854956281");
 
             var result = controller.Show("74828", "pl") as ViewResult;
+            Assert.IsInstanceOfType(typeof(InvoiceDetailsViewData), result.ViewData.Model);
+            
             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
-
+            Assert.That(view.vPlatnosciEcard.Faktura_Numer, Is.EqualTo("27/ASZ/2009"));            
+        }
+        [Test]
+        [Category("Unit")]
+        public void AfterPay_PaymentIsNotValid()
+        {
+            FakeDataContext fake = new FakeDataContext();
+            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
+
+            vPlatnosciEcard platnosc = createPayment(74828, "854956281", "27/ASZ/2009", 200, 2);
+            _rep.Insert(platnosc);
+
+            var controller = new PlatnoscController(fake);
+            controller.ControllerContext = createControllerContext("854956281");
+            
+            Payer payer = createPayer(74828, "", "test");  //Brak 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";
-
+        public void AfterPay_PaymentIsValid()
+        {
+            FakeDataContext fake = new FakeDataContext();
+            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
+
+            vPlatnosciEcard platnosc = createPayment(74828, "854956281", "27/ASZ/2009", 200, 2);
+            _rep.Insert(platnosc);
+
+            var controller = new PlatnoscController(fake);
+            controller.ControllerContext = createControllerContext("854956281");
+
+            Payer payer = createPayer(74828, "test", "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")]
@@ -281,5 +284,4 @@
             ie.TextField(Find.ByName("nip")).TypeText("501379568");
             ie.Button(Find.ById("but")).Click();
-
             Assert.IsTrue(ie.ContainsText("została uregulowana"));
         }
@@ -292,5 +294,4 @@
             ie.TextField(Find.ByName("nip")).TypeText("");
             ie.Button(Find.ById("but")).Click();
-
             Assert.IsTrue(ie.ContainsText("Logowanie nie powiodło się"));
         }
Index: trunk/eCard/eCardMVC/Platnosci.Tests/Web/FakeDataContext.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Tests/Web/FakeDataContext.cs (revision 872)
+++ trunk/eCard/eCardMVC/Platnosci.Tests/Web/FakeDataContext.cs (revision 872)
@@ -0,0 +1,113 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using Platnosci.Core.Interface;
+
+namespace Platnosci.Core.Linq
+{
+    public class FakeDataContext : IDataContext
+    {
+        private List<vPlatnosciEcard> listaPlatnosci = new List<vPlatnosciEcard>();
+        private List<PotwierdzeniaEcard> listaPotwierdzenia = new List<PotwierdzeniaEcard>();
+        private List<PlatnosciEcard> listaPl = new List<PlatnosciEcard>();
+        private List<object> lista = new List<object>();
+
+        public vPlatnosciEcard DodajPlatnosc(int id, string numer, string nip)
+        {
+            vPlatnosciEcard p = new vPlatnosciEcard();
+            p.ID_faktury = id;
+            p.Faktura_Numer = numer;
+            p.nip = nip;
+            
+            return p;
+        }
+        public PotwierdzeniaEcard DodajPotwierdzenie(string code, int ordernumber)
+        {
+            PotwierdzeniaEcard potwierdzenie = new PotwierdzeniaEcard();
+            potwierdzenie.VALIDATIONCODE = code;
+            potwierdzenie.ORDERNUMBER = ordernumber;
+
+            return potwierdzenie;
+        }
+        public PlatnosciEcard createNewPayment(int ordernumber, bool status, DateTime data, int id_faktury)
+        {
+            PlatnosciEcard platnosc = new PlatnosciEcard();
+            platnosc.ORDERNUMBER = ordernumber;
+            platnosc.Status = status;
+            platnosc.Status_data = data;
+            platnosc.IDFaktury = id_faktury;
+
+            return platnosc;
+        }
+        public FakeDataContext()
+        {
+            listaPlatnosci.Add(DodajPlatnosc(1,"1","123"));
+            listaPlatnosci.Add(DodajPlatnosc(2, "2", "aaa"));
+        }
+        public FakeDataContext(int i)
+        {
+            listaPlatnosci.Add(DodajPlatnosc(128, "numerfaktury", "nip"));
+            listaPl.Add(createNewPayment(158, true, DateTime.Now, 128));            
+            listaPotwierdzenia.Add(DodajPotwierdzenie("000", 158));
+        }
+        public IQueryable<T> GetTable<T>() where T : class
+        {
+            var query = from objects in lista	
+	            where typeof(T).IsAssignableFrom(objects.GetType())	
+	            select objects;
+	        return query.Select(o => (T)o).AsQueryable();
+        }
+        public void Insert<T>(T item) where T : class
+        {
+            lista.Add(item);
+        }
+        public void Delete<T>(T item) where T : class
+        {
+            lista.Remove(item);
+        }
+        public IQueryable<vPlatnosciEcard> FindInvoiceById(int id)
+	    {
+            List<object> lp = lista;
+            for (int i = 0; i < lp.Count(); i++)
+            {
+                if (lp[i].GetType() == typeof(vPlatnosciEcard))
+                {
+                    listaPlatnosci.Add((vPlatnosciEcard)lp[i]);
+                }
+            }
+            lista.Clear();
+
+            var query = from l in listaPlatnosci
+                        where l.ID_faktury == id 
+	                    select l;
+                
+            return query.AsQueryable();
+	    }
+        public IQueryable<vPlatnosciEcard> FindInvoiceByNipNumber(string nip, string numer)
+        {
+            var query = from l in listaPlatnosci
+                        where l.nip == nip && l.Faktura_Numer == numer
+                        select l;
+
+            return query.AsQueryable();
+        }
+        public List<PotwierdzeniaEcard> FindItemsByIdFaktury(int idFaktury)
+        {
+            List<PotwierdzeniaEcard> listazaplaconych = new List<PotwierdzeniaEcard>();
+            for (int j = 0; j < listaPl.Count(); j++)
+            {
+                for (int i = 0; i < listaPotwierdzenia.Count(); i++)
+                {
+                    if (listaPl[j].IDFaktury == idFaktury && listaPl[j].ORDERNUMBER == listaPotwierdzenia[i].ORDERNUMBER && listaPotwierdzenia[i].VALIDATIONCODE == "000") listazaplaconych.Add(listaPotwierdzenia[i]);
+                }
+            }
+            return listazaplaconych;
+        }
+        public void SubmitChanges()
+        {
+            
+        }
+        
+    }
+}
