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

Wersja 985, 4.4 KB (wprowadzona przez alina, 16 years temu)

re #215 dodanie testow interfejsowych, dotyczacych walidacji danych, przeslanych z eCardu, modyfikacje w odczycie danych przesylanych z eCardu

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;
10using WatiN.Core;
11
12namespace adMoto.Payments.Test.UI
13{
14    public class UIHelper
15    {
16        private readonly TestDataHelper _testDataHelper = new TestDataHelper();
17        private IRepository<FAKTURY> _repInvoices;
18        private IRepository<FAKTURA_DETAIL> _repInvoiceDetails;
19        private IRepository<PlatnosciEcard> _repPayment;
20        private UIData uiData;
21        private string nip = "test";    //testowy klient o id 76131
22        private string numer_faktury = "1/SLJ/1";       
23        public static string LoginSite = "http://localhost:3646/pl/Account/LogOn";
24        public static string ConfirmForm = "http://localhost:3646/pl/Platnosc/Form";
25
26        public UIData CreateAndAddTestRecordToRepository(int amount)
27        {   
28            _repInvoices = new Repository<FAKTURY>(new DataContext());
29            var invoices = new FAKTURY
30                               {
31                                   NUMER = 1,
32                                   NUMER_ROZ = "SLJ",
33                                   NUMER_ROK = 1,                                       
34                                   NABYWCA_NIP = nip,
35                                   ID_SPRZEDAWCY = 2,
36                                   ID_NABYWCY = 76131,  //testowy klient
37                                   waluta_brutto = Convert.ToDouble(amount),
38                                   waluta_miano = "EUR"
39                               };
40            _repInvoices.Insert(invoices);
41            var invoice = _repInvoices.FindOne(p => p.NUMER == 1 && p.NUMER_ROK == 1 && p.NUMER_ROZ == "SLJ" && p.ID_NABYWCY == 76131);
42
43            if (invoice != null)
44            {
45                _repInvoiceDetails = new Repository<FAKTURA_DETAIL>(new DataContext());
46                var invoiceDetails = new FAKTURA_DETAIL
47                                        {
48                                            ID_FAKTURY = invoice.ID_FAKTURY,
49                                            SYMBOL_SWW = "TEST"
50                                        };
51                _repInvoiceDetails.Insert(invoiceDetails);
52
53                var invoiceDetails2 = _repInvoiceDetails.FindOne(p => p.ID_FAKTURY == invoiceDetails.ID_FAKTURY && p.SYMBOL_SWW == "TEST");
54
55                if (invoiceDetails2 != null)
56                {
57                    uiData = new UIData
58                                {
59                                    FAKTURA_ID = Convert.ToInt32(invoiceDetails2.ID_FAKTURY),
60                                    FAKTURA_DETAIL_ID = invoiceDetails2.ID_FAKTURA_DETAILS,
61                                    Test_nip = nip,
62                                    Test_numer_faktury = numer_faktury
63                                };
64                }
65            }
66            return uiData;
67        }
68       
69        public void DeleteTestRecordsFromRepository(UIData uiData)
70        {
71            var invoice = _repInvoices.FindOne(p => p.ID_FAKTURY == uiData.FAKTURA_ID);
72            if (invoice != null)
73                _repInvoices.Delete(invoice);
74
75            var invoiceDetails = _repInvoiceDetails.FindOne(p => p.ID_FAKTURA_DETAILS == uiData.FAKTURA_DETAIL_ID);
76            if (invoiceDetails != null)
77                _repInvoiceDetails.Delete(invoiceDetails);
78        }
79
80        public void DeleteTestPaymentFromRepository(UIData uiData)
81        {
82            _repPayment = new Repository<PlatnosciEcard>(new DataContext());
83            var payment = _repPayment.FindOne(p => p.IDFaktury == uiData.FAKTURA_ID &&
84                                                   p.NAME == uiData.Test_firstname &&
85                                                   p.SURNAME == uiData.Test_surname &&
86                                                   p.ORDERDESCRIPTION == uiData.Test_numer_faktury &&
87                                                   p.nip == uiData.Test_nip);
88
89            if (payment != null)
90                _repPayment.Delete(payment);
91        }
92       
93        public void CloseWebBrowser(IE ie)
94        {
95            ie.ForceClose();
96            ie.Close();
97            ie.Dispose();
98        }       
99    }
100}
Notatka: Zobacz TracBrowser aby uzyskać więcej informacji.