| 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 | using System.Linq;
|
|---|
| 4 | using Platnosci.Core.Interface;
|
|---|
| 5 | using Platnosci.Core.Linq;
|
|---|
| 6 |
|
|---|
| 7 | namespace Platnosci.Tests.Web
|
|---|
| 8 | {
|
|---|
| 9 | public class FakeDataContext : IDataContext
|
|---|
| 10 | {
|
|---|
| 11 | private const string CODE_OK = "payment_deposited"; //transakcja potwierdzona do rozliczenia
|
|---|
| 12 |
|
|---|
| 13 | private readonly List<object> _lista = new List<object>();
|
|---|
| 14 | private readonly Function _function = new Function();
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 | public IQueryable<T> GetTable<T>() where T : class
|
|---|
| 18 | {
|
|---|
| 19 | var query = _lista.Where(objects => typeof(T).IsAssignableFrom(objects.GetType()));
|
|---|
| 20 | return query.Select(o => (T)o).AsQueryable();
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | public void Insert<T>(T item) where T : class
|
|---|
| 24 | {
|
|---|
| 25 | _lista.Add(item);
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | public void Delete<T>(T item) where T : class
|
|---|
| 29 | {
|
|---|
| 30 | _lista.Remove(item);
|
|---|
| 31 | }
|
|---|
| 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 | }
|
|---|
| 49 | public IQueryable<vPlatnosciEcard> FindInvoiceByNipNumber(string nip, string numer)
|
|---|
| 50 | {
|
|---|
| 51 | throw new NotImplementedException();
|
|---|
| 52 | }
|
|---|
| 53 | public List<PotwierdzeniaEcard> FindItemsByIdFaktury(int idFaktury)
|
|---|
| 54 | {
|
|---|
| 55 |
|
|---|
| 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]};
|
|---|
| 59 | payment.Add(platnosc);
|
|---|
| 60 |
|
|---|
| 61 | var newConfirm = new List<PotwierdzeniaEcard>();
|
|---|
| 62 |
|
|---|
| 63 | if (platnosc.IDFaktury == idFaktury)
|
|---|
| 64 | {
|
|---|
| 65 | if (listaConfirm[0].ORDERNUMBER == platnosc.ORDERNUMBER && listaConfirm[0].CURRENTSTATE == CODE_OK)
|
|---|
| 66 | newConfirm.Add(listaConfirm[0]);
|
|---|
| 67 | }
|
|---|
| 68 | System.Diagnostics.Debug.WriteLine("lista" + newConfirm.Count());
|
|---|
| 69 | return newConfirm;
|
|---|
| 70 | }
|
|---|
| 71 | public int GetOrdernumber(string desc, int? id, DateTime? data)
|
|---|
| 72 | {
|
|---|
| 73 | throw new NotImplementedException();
|
|---|
| 74 | }
|
|---|
| 75 | }
|
|---|
| 76 | }
|
|---|