using System; using System.Collections.Generic; using System.Linq; using Platnosci.Core.Interface; using Platnosci.Core.Linq; namespace Platnosci.Tests.Web { public class FakeDataContext : IDataContext { private const string CODE_OK = "payment_deposited"; //transakcja potwierdzona do rozliczenia private readonly List _lista = new List(); private readonly Function _function = new Function(); public IQueryable GetTable() where T : class { var query = _lista.Where(objects => typeof(T).IsAssignableFrom(objects.GetType())); return query.Select(o => (T)o).AsQueryable(); } public void Insert(T item) where T : class { _lista.Add(item); } public void Delete(T item) where T : class { _lista.Remove(item); } public void SubmitChanges() { InvokeCompleted(EventArgs.Empty); } public event EventHandler Completed; private void InvokeCompleted(EventArgs e) { var completedHandler = Completed; if (completedHandler != null) completedHandler(this, e); } public void Dispose() { } public IQueryable FindInvoiceByNipNumber(string nip, string numer) { throw new NotImplementedException(); } public List FindItemsByIdFaktury(int idFaktury) { var platnosc = _function.CreateNewPayment(123456, true, DateTime.Now, 123); var payment = new List(); var listaConfirm = new List {(PotwierdzeniaEcard) _lista[0]}; payment.Add(platnosc); var newConfirm = new List(); if (platnosc.IDFaktury == idFaktury) { if (listaConfirm[0].ORDERNUMBER == platnosc.ORDERNUMBER && listaConfirm[0].CURRENTSTATE == CODE_OK) newConfirm.Add(listaConfirm[0]); } System.Diagnostics.Debug.WriteLine("lista" + newConfirm.Count()); return newConfirm; } public int GetOrdernumber(string desc, int? id, DateTime? data) { throw new NotImplementedException(); } } }