root/trunk/eCard/eCardMVC/Platnosci.Tests/Web/FakeDataContext.cs @ 896

Wersja 896, 2.5 KB (wprowadzona przez alina, 16 years temu)

re #215 zmiana parametrow w konstruktorze PlatnosciController?, dostosowanie testow do zmiany

RevLine 
[872]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5using Platnosci.Core.Interface;
[896]6using Platnosci.Core.Linq;
[872]7
[896]8namespace Platnosci.Tests.Web
[872]9{
10    public class FakeDataContext : IDataContext
11    {
[896]12        private List<PlatnosciEcard> listaPayment = new List<PlatnosciEcard>();
13       
[883]14        private string code_Ok = "payment_deposited";        //transakcja potwierdzona do rozliczenia
[896]15       
16        private readonly List<object> lista = new List<object>();
17        private Function _f = new Function();
18 
[872]19
20        public IQueryable<T> GetTable<T>() where T : class
21        {
[896]22            var query = lista.Where(objects => typeof(T).IsAssignableFrom(objects.GetType()));
[888]23            return query.Select(o => (T)o).AsQueryable();
[872]24        }
[888]25
[872]26        public void Insert<T>(T item) where T : class
27        {
[896]28            lista.Add(item);
[872]29        }
[888]30
[872]31        public void Delete<T>(T item) where T : class
32        {
[896]33            lista.Remove(item);
[872]34        }
[888]35
36        public void SubmitChanges()
37        {
38            InvokeCompleted(EventArgs.Empty);
39        }
40
41        public event EventHandler Completed;
42
43        private void InvokeCompleted(EventArgs e)
44        {
45            var completedHandler = Completed;
46            if (completedHandler != null) completedHandler(this, e);
47        }
48
49        public void Dispose()
50        {
51        }
[872]52        public IQueryable<vPlatnosciEcard> FindInvoiceByNipNumber(string nip, string numer)
53        {
[896]54            throw new NotImplementedException();
[872]55        }
56        public List<PotwierdzeniaEcard> FindItemsByIdFaktury(int idFaktury)
57        {
[896]58           
59            PlatnosciEcard platnosc = _f.createNewPayment(123456, true, DateTime.Now, 123);
60            List<PlatnosciEcard> payment = new List<PlatnosciEcard>();
61            List<PotwierdzeniaEcard> listaConfirm = new List<PotwierdzeniaEcard>();
62            listaConfirm.Add((PotwierdzeniaEcard)lista[0]);
63            payment.Add(platnosc);
64
65            List<PotwierdzeniaEcard> new_confirm = new List<PotwierdzeniaEcard>();
66
67            if (platnosc.IDFaktury == idFaktury)
[872]68            {
[896]69                if (listaConfirm[0].ORDERNUMBER == platnosc.ORDERNUMBER && listaConfirm[0].CURRENTSTATE == code_Ok)
70                    new_confirm.Add(listaConfirm[0]);
[872]71            }
[896]72            System.Diagnostics.Debug.WriteLine("lista" + new_confirm.Count()); 
73            return new_confirm;
[872]74        }
75    }
76}
Notatka: Zobacz TracBrowser aby uzyskać więcej informacji.