Pokaż
Ignoruj:
Data:
2009-11-24 12:24:57 (16 years ago)
Autor:
alina
Opis:

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

Pliki:
1 zmodyfikowane

Legenda:

Bez zmian
Dodane
Usunięte
  • trunk/eCard/eCardMVC/Platnosci.Tests/Web/FakeDataContext.cs

    r888 r896  
    44using System.Web; 
    55using Platnosci.Core.Interface; 
     6using Platnosci.Core.Linq; 
    67 
    7 namespace Platnosci.Core.Linq 
     8namespace Platnosci.Tests.Web 
    89{ 
    910    public class FakeDataContext : IDataContext 
    1011    { 
    11         private List<vPlatnosciEcard> listaPlatnosci = new List<vPlatnosciEcard>(); 
    12         private List<PotwierdzeniaEcard> listaPotwierdzenia = new List<PotwierdzeniaEcard>(); 
    13         private List<PlatnosciEcard> listaPl = new List<PlatnosciEcard>(); 
    14         private List<object> lista = new List<object>(); 
     12        private List<PlatnosciEcard> listaPayment = new List<PlatnosciEcard>(); 
     13        
    1514        private string code_Ok = "payment_deposited";        //transakcja potwierdzona do rozliczenia 
    16         private string code_Bad = "payment_declined";        //transakcja odrzucona  
    17  
    18         public vPlatnosciEcard DodajPlatnosc(int id, string numer, string nip) 
    19         { 
    20             vPlatnosciEcard p = new vPlatnosciEcard(); 
    21             p.ID_faktury = id; 
    22             p.Faktura_Numer = numer; 
    23             p.nip = nip; 
    24              
    25             return p; 
    26         } 
    27         public PotwierdzeniaEcard DodajPotwierdzenie(string code, int ordernumber) 
    28         { 
    29             PotwierdzeniaEcard potwierdzenie = new PotwierdzeniaEcard(); 
    30             potwierdzenie.CURRENTSTATE = code; 
    31             potwierdzenie.ORDERNUMBER = ordernumber; 
    32  
    33             return potwierdzenie; 
    34         } 
    35         public PlatnosciEcard createNewPayment(int ordernumber, bool status, DateTime data, int id_faktury) 
    36         { 
    37             PlatnosciEcard platnosc = new PlatnosciEcard(); 
    38             platnosc.ORDERNUMBER = ordernumber; 
    39             platnosc.Status = status; 
    40             platnosc.Status_data = data; 
    41             platnosc.IDFaktury = id_faktury; 
    42  
    43             return platnosc; 
    44         } 
    45         public FakeDataContext() 
    46         { 
    47             listaPlatnosci.Add(DodajPlatnosc(1,"1","123")); 
    48             listaPlatnosci.Add(DodajPlatnosc(2, "2", "aaa")); 
    49         } 
    50         //public FakeDataContext(int fake) 
    51         //{ 
    52         //    if (fake == 1) 
    53         //    { 
    54         //        listaPlatnosci.Add(DodajPlatnosc(1000, "abcd", "12345")); 
    55         //        listaPl.Add(createNewPayment(9999, true, DateTime.Now, 1000)); 
    56         //        listaPotwierdzenia.Add(DodajPotwierdzenie(code_Ok, 9999)); 
    57         //    } 
    58         //    else if (fake == 2) 
    59         //    { 
    60         //        listaPl.Add(createNewPayment(9999, false, DateTime.Now, 1000)); 
    61         //    } 
    62         //} 
    63  
    64  
    65         private readonly List<object> _dataStore = new List<object>(); 
     15        
     16        private readonly List<object> lista = new List<object>(); 
     17        private Function _f = new Function(); 
     18  
    6619 
    6720        public IQueryable<T> GetTable<T>() where T : class 
    6821        { 
    69             var query = _dataStore.Where(objects => typeof(T).IsAssignableFrom(objects.GetType())); 
     22            var query = lista.Where(objects => typeof(T).IsAssignableFrom(objects.GetType())); 
    7023            return query.Select(o => (T)o).AsQueryable(); 
    7124        } 
     
    7326        public void Insert<T>(T item) where T : class 
    7427        { 
    75             _dataStore.Add(item); 
     28            lista.Add(item); 
    7629        } 
    7730 
    7831        public void Delete<T>(T item) where T : class 
    7932        { 
    80             _dataStore.Remove(item); 
     33            lista.Remove(item); 
    8134        } 
    8235 
     
    9750        { 
    9851        } 
    99  
    100         public IQueryable<vPlatnosciEcard> FindInvoiceById(int id) 
    101             { 
    102             List<object> lp = lista; 
    103             for (int i = 0; i < lp.Count(); i++) 
    104             { 
    105                 if (lp[i].GetType() == typeof(vPlatnosciEcard)) 
    106                 { 
    107                     listaPlatnosci.Add((vPlatnosciEcard)lp[i]); 
    108                 } 
    109             } 
    110             lista.Clear(); 
    111  
    112             var query = from l in listaPlatnosci 
    113                         where l.ID_faktury == id  
    114                             select l; 
    115                  
    116             return query.AsQueryable(); 
    117             } 
    11852        public IQueryable<vPlatnosciEcard> FindInvoiceByNipNumber(string nip, string numer) 
    11953        { 
    120             List<object> lp = lista; 
    121             for (int i = 0; i < lp.Count(); i++) 
    122             { 
    123                 if (lp[i].GetType() == typeof(vPlatnosciEcard)) 
    124                 { 
    125                     listaPlatnosci.Add((vPlatnosciEcard)lp[i]); 
    126                 } 
    127             } 
    128             lista.Clear(); 
    129  
    130             var query = from l in listaPlatnosci 
    131                         where l.nip == nip && l.Faktura_Numer == numer 
    132                         select l; 
    133  
    134             return query.AsQueryable(); 
     54            throw new NotImplementedException(); 
    13555        } 
    13656        public List<PotwierdzeniaEcard> FindItemsByIdFaktury(int idFaktury) 
    13757        { 
    138             List<PotwierdzeniaEcard> listazaplaconych = new List<PotwierdzeniaEcard>(); 
    139             for (int j = 0; j < listaPl.Count(); j++) 
     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)  
    14068            { 
    141                 for (int i = 0; i < listaPotwierdzenia.Count(); i++) 
    142                 { 
    143                     if (listaPl[j].IDFaktury == idFaktury && listaPl[j].ORDERNUMBER == listaPotwierdzenia[i].ORDERNUMBER && listaPotwierdzenia[i].CURRENTSTATE == code_Ok) listazaplaconych.Add(listaPotwierdzenia[i]); 
    144                 } 
     69                if (listaConfirm[0].ORDERNUMBER == platnosc.ORDERNUMBER && listaConfirm[0].CURRENTSTATE == code_Ok) 
     70                    new_confirm.Add(listaConfirm[0]); 
    14571            } 
    146             return listazaplaconych; 
    147         } 
    148         public IQueryable<PlatnosciEcard> FindPaymentByOrdernumber(int ordernumber) 
    149         { 
    150             var query = from l in listaPl 
    151                         where l.ORDERNUMBER == ordernumber 
    152                         select l; 
    153  
    154             return query.AsQueryable(); 
     72            System.Diagnostics.Debug.WriteLine("lista" + new_confirm.Count());   
     73            return new_confirm; 
    15574        } 
    15675    }