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

Wersja 971, 2.4 KB (wprowadzona przez marek, 16 years temu)

re #215

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