root/trunk/eCard/eCardMVC/adMoto.Payments.Test/UI/UIHelper.cs @ 984

Wersja 984, 4.0 KB (wprowadzona przez alina, 16 years temu)

re #215 ujednolicenie nazw obiektow, modyfikacje dotyczace testow interfejsowych (dodanie tymczasowych rekowrdow do bazy na czas testowania )

Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using adMoto.Payments.Core.Data;
6using adMoto.Payments.Test.Fakes;
7using adMoto.Payments.Web.Models;
8using adMoto.Payments.Core;
9using adMoto.Payments.Core.Interfaces;
10
11namespace adMoto.Payments.Test.UI
12{
13    public class UIHelper
14    {
15        private readonly TestDataHelper _testDataHelper = new TestDataHelper();
16        private IRepository<FAKTURY> _repInvoices;
17        private IRepository<FAKTURA_DETAIL> _repInvoiceDetails;
18        private IRepository<PlatnosciEcard> _repPayment;
19        private UIData uiData;
20        private string nip = "test";    //testowy klient o id 76131
21        private string numer_faktury = "1/SLJ/1";
22
23        public UIData CreateAndAddTestRecordToRepository(int amount)
24        {   
25            _repInvoices = new Repository<FAKTURY>(new DataContext());
26            var invoices = new FAKTURY
27                               {
28                                   NUMER = 1,
29                                   NUMER_ROZ = "SLJ",
30                                   NUMER_ROK = 1,                                       
31                                   NABYWCA_NIP = nip,
32                                   ID_SPRZEDAWCY = 2,
33                                   ID_NABYWCY = 76131,  //testowy klient
34                                   waluta_brutto = Convert.ToDouble(amount),
35                                   waluta_miano = "EUR"
36                               };
37            _repInvoices.Insert(invoices);
38            var invoice = _repInvoices.FindOne(p => p.NUMER == 1 && p.NUMER_ROK == 1 && p.NUMER_ROZ == "SLJ" && p.ID_NABYWCY == 76131);
39
40            if (invoice != null)
41            {
42                _repInvoiceDetails = new Repository<FAKTURA_DETAIL>(new DataContext());
43                var invoiceDetails = new FAKTURA_DETAIL
44                                        {
45                                            ID_FAKTURY = invoice.ID_FAKTURY,
46                                            SYMBOL_SWW = "TEST"
47                                        };
48                _repInvoiceDetails.Insert(invoiceDetails);
49
50                var invoiceDetails2 = _repInvoiceDetails.FindOne(p => p.ID_FAKTURY == invoiceDetails.ID_FAKTURY && p.SYMBOL_SWW == "TEST");
51
52                if (invoiceDetails2 != null)
53                {
54                    uiData = new UIData
55                                {
56                                    FAKTURA_ID = Convert.ToInt32(invoiceDetails2.ID_FAKTURY),
57                                    FAKTURA_DETAIL_ID = invoiceDetails2.ID_FAKTURA_DETAILS,
58                                    Test_nip = nip,
59                                    Test_numer_faktury = numer_faktury
60                                };
61                }
62            }
63            return uiData;
64        }
65       
66        public void DeleteTestRecordsFromRepository(UIData uiData)
67        {
68            var invoice = _repInvoices.FindOne(p => p.ID_FAKTURY == uiData.FAKTURA_ID);
69            if (invoice != null)
70                _repInvoices.Delete(invoice);
71
72            var invoiceDetails = _repInvoiceDetails.FindOne(p => p.ID_FAKTURA_DETAILS == uiData.FAKTURA_DETAIL_ID);
73            if (invoiceDetails != null)
74                _repInvoiceDetails.Delete(invoiceDetails);
75        }
76
77        public void DeleteTestPaymentFromRepository(UIData uiData)
78        {
79            _repPayment = new Repository<PlatnosciEcard>(new DataContext());
80            var payment = _repPayment.FindOne(p => p.IDFaktury == uiData.FAKTURA_ID &&
81                                                   p.NAME == uiData.Test_firstname &&
82                                                   p.SURNAME == uiData.Test_surname &&
83                                                   p.ORDERDESCRIPTION == uiData.Test_numer_faktury &&
84                                                   p.nip == uiData.Test_nip);
85
86            if (payment != null)
87                _repPayment.Delete(payment);
88        }
89       
90    }
91}
Notatka: Zobacz TracBrowser aby uzyskać więcej informacji.