| 1 | using NUnit.Framework;
|
|---|
| 2 | using Platnosci.Core.Linq;
|
|---|
| 3 | using Platnosci.Models;
|
|---|
| 4 | using System.Linq;
|
|---|
| 5 | using Platnosci.Core.Interface;
|
|---|
| 6 |
|
|---|
| 7 | namespace Platnosci.Tests.Web
|
|---|
| 8 | {
|
|---|
| 9 | [TestFixture]
|
|---|
| 10 | class TestMethods
|
|---|
| 11 | {
|
|---|
| 12 | private readonly Function _function = new Function();
|
|---|
| 13 | private readonly ITranslateManager _translateManager = new FakeTranslation();
|
|---|
| 14 |
|
|---|
| 15 | [Test]
|
|---|
| 16 | [Category("Unit")]
|
|---|
| 17 | public void TestInsertMethodForPayment()
|
|---|
| 18 | {
|
|---|
| 19 | var fake = new FakeDataContext();
|
|---|
| 20 | var vPlatnosciEcardRepository = new Repository<vPlatnosciEcard>(fake);
|
|---|
| 21 |
|
|---|
| 22 | var platnosc = _function.CreateInvoice(123, "nip", "", 0, 0);
|
|---|
| 23 | vPlatnosciEcardRepository.Insert(platnosc);
|
|---|
| 24 |
|
|---|
| 25 | System.Diagnostics.Debug.WriteLine("rep.Count: " + vPlatnosciEcardRepository.Count());
|
|---|
| 26 | var pl = vPlatnosciEcardRepository.FindOne(123);
|
|---|
| 27 | System.Diagnostics.Debug.WriteLine("Wartosc nip ma byc 'nip'. Jest " + pl.nip);
|
|---|
| 28 | Assert.That(pl.nip, Is.EqualTo("nip"));
|
|---|
| 29 | }
|
|---|
| 30 | [Test]
|
|---|
| 31 | [Category("Unit")]
|
|---|
| 32 | public void TestMethodCreateAndAddNewPaymentOk()
|
|---|
| 33 | {
|
|---|
| 34 | var idFaktury = 123;
|
|---|
| 35 | var repPayment = new Repository<PlatnosciEcard>(new FakeDataContext());
|
|---|
| 36 | var funkcjePlatnosci = new FunkcjePlatnosci(repPayment, _translateManager);
|
|---|
| 37 | var invoice = _function.CreateInvoice(idFaktury, "nip", "abc/2009", 200, 2);
|
|---|
| 38 | var payer = _function.CreatePayer(idFaktury, "test", "test");
|
|---|
| 39 | var waluta = new Waluta {Amount = 200, Currency = "PLN"};
|
|---|
| 40 | var result = funkcjePlatnosci.CreateAndAddNewPyment(invoice, waluta ,payer, "sessionId");
|
|---|
| 41 |
|
|---|
| 42 | var payment = repPayment.Find(p => p.IDFaktury == 123).SingleOrDefault();
|
|---|
| 43 | Assert.That(payment.IDFaktury, Is.EqualTo(idFaktury));
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | }
|
|---|
| 47 | }
|
|---|