Index: trunk/eCard/eCardMVC/Platnosci.Core/Interface/IDataContext.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Core/Interface/IDataContext.cs (revision 877)
+++ trunk/eCard/eCardMVC/Platnosci.Core/Interface/IDataContext.cs (revision 896)
@@ -14,7 +14,5 @@
         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);
-        IQueryable<PlatnosciEcard> FindPaymentByOrdernumber(int ordernumber);
     }
 }
Index: trunk/eCard/eCardMVC/Platnosci.Core/Interface/IRepository.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Core/Interface/IRepository.cs (revision 888)
+++ trunk/eCard/eCardMVC/Platnosci.Core/Interface/IRepository.cs (revision 896)
@@ -40,9 +40,5 @@
         IQueryable<vPlatnosciEcard> FindInvoiceByNipNumber(string nip, string numer);
 
-        IQueryable<vPlatnosciEcard> FindInvoiceById(int id);
-
         List<PotwierdzeniaEcard> FindItemsByIdFaktury(int idFaktury);
-
-        IQueryable<PlatnosciEcard> FindPaymentByOrdernumber(int ordernumber);
     }
 }
Index: trunk/eCard/eCardMVC/Platnosci.Core/Linq/Repository.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Core/Linq/Repository.cs (revision 888)
+++ trunk/eCard/eCardMVC/Platnosci.Core/Linq/Repository.cs (revision 896)
@@ -88,16 +88,8 @@
             return _dataContext.FindInvoiceByNipNumber(nip, numer);
         }
-        public IQueryable<vPlatnosciEcard> FindInvoiceById(int id)
-        {
-            return _dataContext.FindInvoiceById(id);
-        }
         public List<PotwierdzeniaEcard> FindItemsByIdFaktury(int idFaktury)
         {
             return _dataContext.FindItemsByIdFaktury(idFaktury);
-        }
-        public IQueryable<PlatnosciEcard> FindPaymentByOrdernumber(int ordernumber)
-        {
-            return _dataContext.FindPaymentByOrdernumber(ordernumber);
-        }
+        }       
     }
 }
Index: trunk/eCard/eCardMVC/Platnosci/Controllers/MerchantController.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci/Controllers/MerchantController.cs (revision 881)
+++ trunk/eCard/eCardMVC/Platnosci/Controllers/MerchantController.cs (revision 896)
@@ -30,14 +30,14 @@
         public const string KODOWANIE = "ISO-8859-2";
         private int ORDERNUMBER = 122;
+        private string merchantId;
 
-        private string merchantId;
-        private readonly PlatnosciDataContext _context;
-        private readonly IRepository<PlatnosciEcard> _rep;
+        private readonly IRepository<vPlatnosciEcard> _repVPayment;
+        private readonly IRepository<PlatnosciEcard> _repPayment;        
         private FunkcjePlatnosci _func;
 
         public MerchantController()
-        {   
-            _rep = new Repository<PlatnosciEcard>(new DataContext1());
-            _context = new PlatnosciDataContext();
+        {
+            _repVPayment = new Repository<vPlatnosciEcard>(new DataContext1());
+            _repPayment = new Repository<PlatnosciEcard>(new DataContext1());
             _func = new FunkcjePlatnosci();
         }
@@ -48,5 +48,5 @@
 
             int id1 = Convert.ToInt32(payer.Id_faktury);
-            vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault();
+            vPlatnosciEcard platnosc = _repVPayment.Find(p => p.ID_faktury == id1).SingleOrDefault();
                  
             if (platnosc == null)
@@ -115,5 +115,5 @@
             if (platnosc != null)
             {                
-               // _rep.Insert(platnosc);
+                //_repPayment.Insert(platnosc);
                 return true;
             }
Index: trunk/eCard/eCardMVC/Platnosci/Controllers/PlatnoscController.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci/Controllers/PlatnoscController.cs (revision 888)
+++ trunk/eCard/eCardMVC/Platnosci/Controllers/PlatnoscController.cs (revision 896)
@@ -23,8 +23,7 @@
     {
         public const string ISPAID = "payment_deposited";       //transakcja potwierdzona do rozliczenia
-        private readonly PlatnosciDataContext _context;
-        private readonly IDataContext _context1;
-        private readonly IRepository<PotwierdzeniaEcard> _rep;
-        private readonly IRepository<PlatnosciEcard> _repPl;
+        private readonly IRepository<vPlatnosciEcard> _repVPayment;       
+        private readonly IRepository<PlatnosciEcard> _repPayment;
+        private readonly IRepository<PotwierdzeniaEcard> _repConfirm;       
         private FunkcjePlatnosci _func;
         private string weryfikacja;
@@ -37,15 +36,14 @@
         public PlatnoscController()
         {
-            _context = new PlatnosciDataContext();
-            _rep = new Repository<PotwierdzeniaEcard>(new DataContext1());
-            _repPl = new Repository<PlatnosciEcard>(new DataContext1());
-            _func = new FunkcjePlatnosci();
-                      
-        }
-        public PlatnoscController(IDataContext datacontext, int czy_test)
-        {
-            _rep = new Repository<PotwierdzeniaEcard>(datacontext);
-            _repPl = new Repository<PlatnosciEcard>(datacontext);
-            _context1 = datacontext;
+            _repVPayment = new Repository<vPlatnosciEcard>(new DataContext1());
+            _repPayment = new Repository<PlatnosciEcard>(new DataContext1());
+            _repConfirm = new Repository<PotwierdzeniaEcard>(new DataContext1());
+            _func = new FunkcjePlatnosci();                      
+        }
+        public PlatnoscController(IRepository<vPlatnosciEcard> repVPayment, IRepository<PlatnosciEcard> repPayment, IRepository<PotwierdzeniaEcard> repConfirm, int czy_test)
+        {
+            _repVPayment = repVPayment;
+            _repPayment = repPayment;
+            _repConfirm = repConfirm;
             _func = new FunkcjePlatnosci();
             test = czy_test;
@@ -57,5 +55,5 @@
             int id1 = ConvertId(id);
 
-            vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault();
+            vPlatnosciEcard platnosc = _repVPayment.Find(p => p.ID_faktury == id1).SingleOrDefault();
             if (!String.IsNullOrEmpty(Iserror(platnosc).error)) return View("Error1", Iserror(platnosc));
 
@@ -65,5 +63,5 @@
             var invoiceDeatailsViewData = InitInvoiceDetailsViewData(platnosc, payer, "", kwota);  
 
-            var tablica_potwierdzenia = _rep.FindItemsByIdFaktury(id1);
+            var tablica_potwierdzenia = _repConfirm.FindItemsByIdFaktury(id1);
             if (tablica_potwierdzenia.Count > 0) //platnosc za fakture zostala uregulowana
             {
@@ -81,5 +79,5 @@
             language = _func.setLanguage(language);
             ustawTlumaczenia(test);
-            vPlatnosciEcard platnosc = _rep.FindInvoiceById(payer.Id_faktury).SingleOrDefault();
+            vPlatnosciEcard platnosc = _repVPayment.Find(p => p.ID_faktury == payer.Id_faktury).SingleOrDefault();
             if (!String.IsNullOrEmpty(Iserror(platnosc).error)) return View("Error1", Iserror(platnosc));
             
@@ -111,5 +109,5 @@
             ustawTlumaczenia(test);
             int id1 = ConvertId(id);
-            vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault();
+            vPlatnosciEcard platnosc = _repVPayment.Find(p => p.ID_faktury == id1).SingleOrDefault();
             if (!String.IsNullOrEmpty(Iserror(platnosc).error)) return View("Error1", Iserror(platnosc));            
             
@@ -122,5 +120,5 @@
             ustawTlumaczenia(test);
             int id1 = ConvertId(id);
-            vPlatnosciEcard platnosc = _rep.FindInvoiceById(id1).SingleOrDefault();
+            vPlatnosciEcard platnosc = _repVPayment.Find(p => p.ID_faktury == id1).SingleOrDefault();
             if (!String.IsNullOrEmpty(Iserror(platnosc).error)) return View("Error1", Iserror(platnosc));
             
@@ -163,5 +161,5 @@
             potwierdzenie.WITHCVC = WITHCVC;
 
-            _rep.Insert(potwierdzenie);
+            _repConfirm.Insert(potwierdzenie);
             UpdateStatus(ORDERNUMBER, CURRENTSTATE);
             return View();
@@ -229,10 +227,10 @@
         public void UpdateStatus(int ordernumber, string currentstate)
         {
-            PlatnosciEcard platnosc = _repPl.FindOne(ordernumber);
+            PlatnosciEcard platnosc = _repPayment.Find(p => p.ORDERNUMBER == ordernumber).SingleOrDefault();
             if (platnosc != null && currentstate == ISPAID)
             {
                 platnosc.Status = true;
                 platnosc.Status_data = DateTime.Now;
-                _repPl.SubmitChanges();
+                _repPayment.SubmitChanges();
                 
                 System.Diagnostics.Debug.WriteLine("IsUpdate");
Index: trunk/eCard/eCardMVC/Platnosci.Tests/Web/PlatnosciControllerTests.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Tests/Web/PlatnosciControllerTests.cs (revision 888)
+++ trunk/eCard/eCardMVC/Platnosci.Tests/Web/PlatnosciControllerTests.cs (revision 896)
@@ -26,49 +26,39 @@
         private string code_Bad = "payment_declined";        //transakcja odrzucona 
         private DateTime data = DateTime.Now;
-        private string testNip1 = "12345";
-        private string testNip2 = "01234";
-        private int testIdFaktury = 1000;
-        private string testNumerFaktury = "abcd";
-        private decimal testBrutto = 200;
+        
         private int test = 1; //oznacza, ze nie ustawiamy tlumaczen poprzez funkcje ustawTlumaczenia()
                               //w controllerze Platnosci, tylko poprzez funkcje setXXXXXXX()
 
         private Function _f = new Function();
-        private FunkcjePlatnosci _func = new FunkcjePlatnosci();
-        
+               
         [Test]
         [Category("Unit")]
         public void Status_Saves_Correct_Transaction()
         {          
-           // //IDataContext fake = new FakeDataContext();
-           // var repository = new Repository<PlatnosciEcard>(new FakeDataContext());
-           // var platnosci = _f.createNewPayment(orderNumber, false, DateTime.Now, 12345); //new PlatnosciEcard();
-           // repository.Insert(platnosci);
-           // repository.SubmitChanges();
-
-
-           // DateTime datka = DateTime.Now;
-           // var builder = new TestControllerBuilder();
-           // var controller = new PlatnoscController(fake,test);
-           // 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());
-           // builder.Form.Add("CURRENTSTATE", code_Ok);           
-           
-           // var result = controller.Status();
-           
-           // IRepository<PotwierdzeniaEcard> _rep = new Repository<PotwierdzeniaEcard>(new FakeDataContext());
-
-
-           // System.Diagnostics.Debug.WriteLine("" + _rep.Count());
-
-           // //var potwierdzeniaEcard = _rep.Find(p => p.ORDERNUMBER == orderNumber).First();
-           //// Assert.That(potwierdzeniaEcard.MERCHANTNUMBER, Is.EqualTo(merchantNumber));
-           // PlatnosciEcard payment_after_update = _rep.FindPaymentByOrdernumber(orderNumber).SingleOrDefault();
-           // System.Diagnostics.Debug.WriteLine(payment_after_update.Status_data + " > " + datka);
-           // Assert.That(payment_after_update.Status, Is.EqualTo(true));
-            
+           var repository = new Repository<PlatnosciEcard>(new FakeDataContext());
+           var platnosci = _f.createNewPayment(orderNumber, false, DateTime.Now, 12345); 
+           repository.Insert(platnosci);
+           repository.SubmitChanges();
+
+           IRepository<PotwierdzeniaEcard> rep = new Repository<PotwierdzeniaEcard>(new FakeDataContext());
+           
+           var builder = new TestControllerBuilder();
+           var controller = new PlatnoscController(null, repository, rep, test);
+           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());
+           builder.Form.Add("CURRENTSTATE", code_Ok);           
+           
+           var result = controller.Status();
+           
+           System.Diagnostics.Debug.WriteLine("rep:" + rep.Count() + " repPl: " + repository.Count() );
+
+           var potwierdzeniaEcard = rep.Find(o => o.ORDERNUMBER == orderNumber).SingleOrDefault();
+           Assert.That(potwierdzeniaEcard.MERCHANTNUMBER, Is.EqualTo(merchantNumber));
+           PlatnosciEcard payment_after_update = repository.FindOne(orderNumber);
+           System.Diagnostics.Debug.WriteLine("Status musi byc 'true'. Jest " + payment_after_update.Status);
+           Assert.That(payment_after_update.Status, Is.EqualTo(true));            
         }
         [Test]
@@ -76,8 +66,12 @@
         public void Status_Saves_Correct_Transaction_IncorrectUpdate()
         {
-            FakeDataContext fake = new FakeDataContext(2);
-            DateTime datka = DateTime.Now;
+            var repPayment = new Repository<PlatnosciEcard>(new FakeDataContext());
+            var platnosci = _f.createNewPayment(orderNumber, false, DateTime.Now, 12345);
+            repPayment.Insert(platnosci);
+            repPayment.SubmitChanges();
+            IRepository<PotwierdzeniaEcard> repConfirm = new Repository<PotwierdzeniaEcard>(new FakeDataContext());
+          
             var builder = new TestControllerBuilder();
-            var controller = new PlatnoscController(fake,test);
+            var controller = new PlatnoscController(null, repPayment, repConfirm, test);
             builder.InitializeController(controller);
             builder.Form.Add("MERCHANTNUMBER", merchantNumber.ToString());
@@ -87,32 +81,28 @@
             builder.Form.Add("CURRENTSTATE", code_Bad);
 
-            var result = controller.Status();
-           
-            IRepository<PotwierdzeniaEcard> _rep = new Repository<PotwierdzeniaEcard>(fake);
-            var potwierdzeniaEcard = _rep.Find(p => p.ORDERNUMBER == orderNumber).First();
+            var result = controller.Status();           
+           
+            var potwierdzeniaEcard = repConfirm.Find(o => o.ORDERNUMBER == orderNumber).SingleOrDefault();
             Assert.That(potwierdzeniaEcard.MERCHANTNUMBER, Is.EqualTo(merchantNumber));
-
             
-            PlatnosciEcard payment_after_update = _rep.FindPaymentByOrdernumber(orderNumber).SingleOrDefault();
-            System.Diagnostics.Debug.WriteLine(payment_after_update.Status_data + " <= " + datka );
-            Assert.That(payment_after_update.Status_data, Is.LessThanOrEqualTo(datka));
-        }
+            PlatnosciEcard payment_after_update = repPayment.FindOne(orderNumber);
+            System.Diagnostics.Debug.WriteLine("Status musi byc 'false'. Jest " + payment_after_update.Status);
+            Assert.That(payment_after_update.Status, Is.EqualTo(false));
+        }
+        
         [Test]
         [Category("Unit")]
         public void StatusIsUpdated()
         {
-            FakeDataContext fake = new FakeDataContext(3);
-            IRepository<PlatnosciEcard> _rep = new Repository<PlatnosciEcard>(fake);
-
-            PlatnosciEcard platnosc = _f.createNewPayment(orderNumber, false, data.AddDays(-1), 1);
-            _rep.Insert(platnosc);
-
-            DateTime datka = DateTime.Now;
-            var controller = new PlatnoscController(fake,test);
+            IRepository<PlatnosciEcard> repPayment = new Repository<PlatnosciEcard>(new FakeDataContext());
+            PlatnosciEcard platnosc = _f.createNewPayment(orderNumber, false, data, 1);
+            repPayment.Insert(platnosc);
+
+            var controller = new PlatnoscController(null, repPayment, null, test);
             controller.UpdateStatus(orderNumber, code_Ok);   
             
             PlatnosciEcard payment_after_update = new PlatnosciEcard();
-            payment_after_update = _rep.FindOne(orderNumber);
-            
+            payment_after_update = repPayment.FindOne(orderNumber);
+            System.Diagnostics.Debug.WriteLine("Status musi byc 'true'. Jest " + payment_after_update.Status);
             Assert.That(payment_after_update.Status, Is.EqualTo(true));
         }
@@ -121,16 +111,16 @@
         public void StatusIsNotUpdated()
         {
-            FakeDataContext fake = new FakeDataContext();
-            IRepository<PlatnosciEcard> _rep = new Repository<PlatnosciEcard>(fake);
-
-            PlatnosciEcard platnosc = _f.createNewPayment(orderNumber, true, data, 1);
-            _rep.Insert(platnosc);
-
-            var controller = new PlatnoscController(fake,test);
+            IRepository<PlatnosciEcard> repPayment = new Repository<PlatnosciEcard>(new FakeDataContext());
+
+            PlatnosciEcard platnosc = _f.createNewPayment(orderNumber, false, data, 1);
+            repPayment.Insert(platnosc);
+
+            var controller = new PlatnoscController(null, repPayment, null, test);
             controller.UpdateStatus(orderNumber, code_Bad);   
 
             PlatnosciEcard payment_after_update = new PlatnosciEcard();
-            payment_after_update = _rep.FindOne(i => i.ORDERNUMBER == orderNumber);
-            Assert.That(payment_after_update.Status_data, Is.EqualTo(data));
+            payment_after_update = repPayment.FindOne(i => i.ORDERNUMBER == orderNumber);
+            System.Diagnostics.Debug.WriteLine("Status musi byc 'false'. Jest " + payment_after_update.Status);
+            Assert.That(payment_after_update.Status, Is.EqualTo(false));
         }        
         [Test]
@@ -138,17 +128,15 @@
         public void ActionShowPayment_IncorrectUserIdentity_ReturnErrorView()
         {
-            FakeDataContext fake = new FakeDataContext();
-            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
-
-            vPlatnosciEcard platnosc = _f.createPayment(testIdFaktury, testNip1, testNumerFaktury, 0, 0);
-            _rep.Insert(platnosc);
-
-            var controller = new PlatnoscController(fake,test);
-            controller.ControllerContext = _f.createControllerContext(testNip2);
+            IRepository<vPlatnosciEcard> repVPayment = new Repository<vPlatnosciEcard>(new FakeDataContext());
+            vPlatnosciEcard platnosc = _f.createInvoice(123, "nip1", "", 0, 0);
+            repVPayment.Insert(platnosc);
+
+            var controller = new PlatnoscController(repVPayment, null, null, test);
+            controller.ControllerContext = _f.createControllerContext("nip2");
             controller.setWeryfikacja("Niepoprawny nip");            
            
-            var result = controller.Show(testIdFaktury.ToString(),"pl") as ViewResult;
+            var result = controller.Show("123","pl") as ViewResult;
             var error = (ErrorViewData)result.ViewData.Model;
-            
+
             Assert.That(error.error, Is.EqualTo("Niepoprawny nip"));
             Assert.That(result.ViewName, Is.EqualTo("Error1"));
@@ -158,13 +146,12 @@
         public void ActionShowPayment_PaymentNotFound_ReturnErrorView()
         {
-            FakeDataContext fake = new FakeDataContext();
-           // IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
-
-            var controller = new PlatnoscController(fake,test);
-
-            controller.ControllerContext = _f.createControllerContext(testNip1);
+            IRepository<vPlatnosciEcard> repVPayment = new Repository<vPlatnosciEcard>(new FakeDataContext());
+            vPlatnosciEcard platnosc = _f.createInvoice(123, "", "", 0, 0);
+            repVPayment.Insert(platnosc);
+
+            var controller = new PlatnoscController(repVPayment, null, null, test);
             controller.setBrakDanych("Platnosc o takim id nie istnieje");
 
-            var result = controller.Show(testIdFaktury.ToString(), "pl") as ViewResult;
+            var result = controller.Show("1234", "pl") as ViewResult;
             var error = (ErrorViewData)result.ViewData.Model;
 
@@ -174,13 +161,22 @@
         [Test]
         [Category("Unit")]
-        public void ActionShowPayment_PaymentIsPaid(){
+        public void ActionShowPayment_PaymentIsPaid()
+        {
             //Tworzymy takie dane aby platnosc o danym id byla juz zaplacona 
-            FakeDataContext fake = new FakeDataContext(1); 
-            var controller = new PlatnoscController(fake,test);
-
-            controller.ControllerContext = _f.createControllerContext(testNip1);
+            var repVPayment = new Repository<vPlatnosciEcard>(new FakeDataContext());
+            var invoice = _f.createInvoice(123, "nip1", "aaa", 0, 0);
+            repVPayment.Insert(invoice);
+            repVPayment.SubmitChanges();
+
+            var repConfirm = new Repository<PotwierdzeniaEcard>(new FakeDataContext());
+            var confirm = _f.createConfirm(code_Ok, 123456);
+            repConfirm.Insert(confirm);
+            repConfirm.SubmitChanges();
+
+            var controller = new PlatnoscController(repVPayment, null, repConfirm, test);
+            controller.ControllerContext = _f.createControllerContext("nip1");
             controller.setZaplacono("Platnosc zostala uregulowana");
 
-            var result = controller.Show(testIdFaktury.ToString(), "pl") as ViewResult;
+            var result = controller.Show("123", "pl") as ViewResult;
             var view = (InvoiceDetailsViewData)result.ViewData.Model;
 
@@ -192,36 +188,37 @@
         public void ActionShowPayment_CorrectData_ReturnViewForPayment()
         {
-            FakeDataContext fake = new FakeDataContext();
-            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
-                                                  
-            vPlatnosciEcard platnosc = _f.createPayment(testIdFaktury, testNip1, testNumerFaktury, testBrutto, 0);
-            _rep.Insert(platnosc);
-
-            var controller = new PlatnoscController(fake,test);
-            controller.ControllerContext = _f.createControllerContext(testNip1);
-
-            var result = controller.Show(testIdFaktury.ToString(), "pl") as ViewResult;
-            Assert.IsInstanceOfType(typeof(InvoiceDetailsViewData), result.ViewData.Model);
+            IRepository<vPlatnosciEcard> repVPayment = new Repository<vPlatnosciEcard>(new FakeDataContext());
+            vPlatnosciEcard platnosc = _f.createInvoice(123, "nip1", "numer", 200, 0);
+            repVPayment.Insert(platnosc);
+
+            var repConfirm = new Repository<PotwierdzeniaEcard>(new FakeDataContext());
+            var confirm = _f.createConfirm(code_Ok, 1);
+            repConfirm.Insert(confirm);
+            repConfirm.SubmitChanges();
+
+            var controller = new PlatnoscController(repVPayment, null, repConfirm, test);
+            controller.ControllerContext = _f.createControllerContext("nip1");
+
+            var result = controller.Show("123", "pl") as ViewResult;
+                      
+            var view = (InvoiceDetailsViewData)result.ViewData.Model;
+            System.Diagnostics.Debug.WriteLine("Brutto 200: " + view.vPlatnosciEcard.Brutto);
+            System.Diagnostics.Debug.WriteLine("Nr Faktury musi byc 'numer'. Jest " + view.vPlatnosciEcard.Faktura_Numer);
+            Assert.That(view.vPlatnosciEcard.Brutto, Is.EqualTo(200));
+            Assert.That(view.vPlatnosciEcard.Faktura_Numer, Is.EqualTo("numer"));            
+        }
+        [Test]
+        [Category("Unit")]
+        public void AfterPay_PaymentIsNotValid()
+        {
+            IRepository<vPlatnosciEcard> repVPayment = new Repository<vPlatnosciEcard>(new FakeDataContext());
+            vPlatnosciEcard platnosc = _f.createInvoice(123, "nip1", "numer", 200, 0);
+            repVPayment.Insert(platnosc);
+
+            var controller = new PlatnoscController(repVPayment, null, null, test);
+            controller.ControllerContext = _f.createControllerContext("nip1");
             
-            var view = (InvoiceDetailsViewData)result.ViewData.Model;
-            Assert.That(view.vPlatnosciEcard.Brutto, Is.EqualTo(testBrutto));
-            Assert.That(view.vPlatnosciEcard.Faktura_Numer, Is.EqualTo(testNumerFaktury));            
-        }
-        [Test]
-        [Category("Unit")]
-        public void AfterPay_PaymentIsNotValid()
-        {
-            FakeDataContext fake = new FakeDataContext();
-            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
-
-            vPlatnosciEcard platnosc = _f.createPayment(testIdFaktury, testNip1, testNumerFaktury, testBrutto, 2);
-            _rep.Insert(platnosc);
-
-            var controller = new PlatnoscController(fake,1);
-            controller.ControllerContext = _f.createControllerContext(testNip1);
-            
-            Payer payer = _f.createPayer(testIdFaktury, "", "test");  //Brak imienia
+            Payer payer = _f.createPayer(123, "", "test");  //Brak imienia
             controller.Show(payer, "pl");
-
             Assert.That(controller.ModelState.IsValid, Is.False);
         }
@@ -230,18 +227,16 @@
         public void AfterPay_PaymentIsValid()
         {
-            FakeDataContext fake = new FakeDataContext();
-            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
-
-            vPlatnosciEcard platnosc = _f.createPayment(testIdFaktury, testNip1, testNumerFaktury, testBrutto, 2);
-            _rep.Insert(platnosc);
-
-            var controller = new PlatnoscController(fake,test);
-            controller.ControllerContext = _f.createControllerContext(testNip1);
-
-            Payer payer = _f.createPayer(testIdFaktury, "test", "test");  
+            IRepository<vPlatnosciEcard> repVPayment = new Repository<vPlatnosciEcard>(new FakeDataContext());
+            vPlatnosciEcard platnosc = _f.createInvoice(123, "nip1", "numer", 200, 0);
+            repVPayment.Insert(platnosc);
+
+            var controller = new PlatnoscController(repVPayment, null, null, test);
+            controller.ControllerContext = _f.createControllerContext("nip1");
+
+            Payer payer = _f.createPayer(123, "test", "test");  
             var result = controller.Show(payer, "pl") as ViewResult;
 
-            System.Diagnostics.Debug.WriteLine("AfterPay_PaymentIsValid_Test");
-            Assert.That(controller.ModelState.IsValid, Is.True, "Model powinien byc true");
+            System.Diagnostics.Debug.WriteLine("Model powinien byc 'true'. Jest " + controller.ModelState.IsValid);
+            Assert.That(controller.ModelState.IsValid, Is.True);
         }
     }
Index: trunk/eCard/eCardMVC/Platnosci.Tests/Web/TestMethods.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Tests/Web/TestMethods.cs (revision 882)
+++ trunk/eCard/eCardMVC/Platnosci.Tests/Web/TestMethods.cs (revision 896)
@@ -12,20 +12,6 @@
     class TestMethods
     {
-        private string testNip1 = "12345";
-        private int testIdFaktury = 1000;
-
         private Function _f = new Function();
 
-        [Test]
-        [Category("Unit")]
-        public void TestFindInvoiceByNumber()
-        {
-            FakeDataContext fake = new FakeDataContext();
-            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
-
-            vPlatnosciEcard platnosc = new vPlatnosciEcard();
-            platnosc = _rep.FindInvoiceById(1).SingleOrDefault();
-            Assert.That(platnosc.Faktura_Numer, Is.EqualTo("1"));
-        }
         [Test]
         [Category("Unit")]
@@ -33,11 +19,13 @@
         {
             FakeDataContext fake = new FakeDataContext();
-            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);
+            var _rep = new Repository<vPlatnosciEcard>(fake);
 
-            vPlatnosciEcard platnosc = _f.createPayment(testIdFaktury, testNip1, "", 0, 0);
+            vPlatnosciEcard platnosc = _f.createInvoice(123, "nip", "", 0, 0);
             _rep.Insert(platnosc);
 
-            vPlatnosciEcard pl = _rep.FindInvoiceById(testIdFaktury).SingleOrDefault();
-            Assert.That(pl.nip, Is.EqualTo(testNip1));
+            System.Diagnostics.Debug.WriteLine("rep.Count: " + _rep.Count());            
+            vPlatnosciEcard pl = _rep.FindOne(123);
+            System.Diagnostics.Debug.WriteLine("Wartosc nip ma byc 'nip'. Jest " + pl.nip);
+            Assert.That(pl.nip, Is.EqualTo("nip"));
         }
     }
Index: trunk/eCard/eCardMVC/Platnosci.Tests/Web/FakeDataContext.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Tests/Web/FakeDataContext.cs (revision 888)
+++ trunk/eCard/eCardMVC/Platnosci.Tests/Web/FakeDataContext.cs (revision 896)
@@ -4,68 +4,21 @@
 using System.Web;
 using Platnosci.Core.Interface;
+using Platnosci.Core.Linq;
 
-namespace Platnosci.Core.Linq
+namespace Platnosci.Tests.Web
 {
     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>();
+        private List<PlatnosciEcard> listaPayment = new List<PlatnosciEcard>();
+       
         private string code_Ok = "payment_deposited";        //transakcja potwierdzona do rozliczenia
-        private string code_Bad = "payment_declined";        //transakcja odrzucona 
-
-        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.CURRENTSTATE = 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 fake)
-        //{
-        //    if (fake == 1)
-        //    {
-        //        listaPlatnosci.Add(DodajPlatnosc(1000, "abcd", "12345"));
-        //        listaPl.Add(createNewPayment(9999, true, DateTime.Now, 1000));
-        //        listaPotwierdzenia.Add(DodajPotwierdzenie(code_Ok, 9999));
-        //    }
-        //    else if (fake == 2)
-        //    {
-        //        listaPl.Add(createNewPayment(9999, false, DateTime.Now, 1000));
-        //    }
-        //}
-
-
-        private readonly List<object> _dataStore = new List<object>();
+       
+        private readonly List<object> lista = new List<object>();
+        private Function _f = new Function();
+ 
 
         public IQueryable<T> GetTable<T>() where T : class
         {
-            var query = _dataStore.Where(objects => typeof(T).IsAssignableFrom(objects.GetType()));
+            var query = lista.Where(objects => typeof(T).IsAssignableFrom(objects.GetType()));
             return query.Select(o => (T)o).AsQueryable();
         }
@@ -73,10 +26,10 @@
         public void Insert<T>(T item) where T : class
         {
-            _dataStore.Add(item);
+            lista.Add(item);
         }
 
         public void Delete<T>(T item) where T : class
         {
-            _dataStore.Remove(item);
+            lista.Remove(item);
         }
 
@@ -97,60 +50,26 @@
         {
         }
-
-        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)
         {
-            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.nip == nip && l.Faktura_Numer == numer
-                        select l;
-
-            return query.AsQueryable();
+            throw new NotImplementedException();
         }
         public List<PotwierdzeniaEcard> FindItemsByIdFaktury(int idFaktury)
         {
-            List<PotwierdzeniaEcard> listazaplaconych = new List<PotwierdzeniaEcard>();
-            for (int j = 0; j < listaPl.Count(); j++)
+            
+            PlatnosciEcard platnosc = _f.createNewPayment(123456, true, DateTime.Now, 123);
+            List<PlatnosciEcard> payment = new List<PlatnosciEcard>();
+            List<PotwierdzeniaEcard> listaConfirm = new List<PotwierdzeniaEcard>();
+            listaConfirm.Add((PotwierdzeniaEcard)lista[0]);
+            payment.Add(platnosc);
+
+            List<PotwierdzeniaEcard> new_confirm = new List<PotwierdzeniaEcard>();
+
+            if (platnosc.IDFaktury == idFaktury) 
             {
-                for (int i = 0; i < listaPotwierdzenia.Count(); i++)
-                {
-                    if (listaPl[j].IDFaktury == idFaktury && listaPl[j].ORDERNUMBER == listaPotwierdzenia[i].ORDERNUMBER && listaPotwierdzenia[i].CURRENTSTATE == code_Ok) listazaplaconych.Add(listaPotwierdzenia[i]);
-                }
+                if (listaConfirm[0].ORDERNUMBER == platnosc.ORDERNUMBER && listaConfirm[0].CURRENTSTATE == code_Ok)
+                    new_confirm.Add(listaConfirm[0]);
             }
-            return listazaplaconych;
-        }
-        public IQueryable<PlatnosciEcard> FindPaymentByOrdernumber(int ordernumber)
-        {
-            var query = from l in listaPl
-                        where l.ORDERNUMBER == ordernumber
-                        select l;
-
-            return query.AsQueryable();
+            System.Diagnostics.Debug.WriteLine("lista" + new_confirm.Count());  
+            return new_confirm;
         }
     }
Index: trunk/eCard/eCardMVC/Platnosci.Tests/Web/Function.cs
===================================================================
--- trunk/eCard/eCardMVC/Platnosci.Tests/Web/Function.cs (revision 888)
+++ trunk/eCard/eCardMVC/Platnosci.Tests/Web/Function.cs (revision 896)
@@ -11,5 +11,5 @@
     public class Function
     {
-        public vPlatnosciEcard createPayment(int id, string nip, string fak_numer, decimal brutto, byte SystemKsiegowy)
+        public vPlatnosciEcard createInvoice(int id, string nip, string fak_numer, decimal brutto, byte SystemKsiegowy)
         {
 
@@ -33,4 +33,12 @@
             return platnosc;
         }
+        public PotwierdzeniaEcard createConfirm(string code, int ordernumber)
+        {
+            PotwierdzeniaEcard potwierdzenie = new PotwierdzeniaEcard();
+            potwierdzenie.CURRENTSTATE = code;
+            potwierdzenie.ORDERNUMBER = ordernumber;
+
+            return potwierdzenie;
+        }
         public Payer createPayer(int id, string name, string surname)
         {
