| 1 | using System.Linq;
|
|---|
| 2 | using NUnit.Framework;
|
|---|
| 3 | using Platnosci.Models;
|
|---|
| 4 | using Platnosci.Core.Linq;
|
|---|
| 5 | using Platnosci.Core.Interface;
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 | namespace Platnosci.Tests.Web
|
|---|
| 9 | {
|
|---|
| 10 | [TestFixture]
|
|---|
| 11 | public class FunkcjePlatnosciTests
|
|---|
| 12 | {
|
|---|
| 13 | private readonly Function _function = new Function();
|
|---|
| 14 | private readonly ITranslateManager _translateManager = new FakeTranslation();
|
|---|
| 15 |
|
|---|
| 16 | [Test, Sequential]
|
|---|
| 17 | [Category("Unit")]
|
|---|
| 18 | public void GetCurrency_Returns_Correct_Currency(
|
|---|
| 19 | [Values(null, "", "eur", "usd", "gbp", "GBP")] string input,
|
|---|
| 20 | [Values(FunkcjePlatnosci.PLN, FunkcjePlatnosci.PLN, FunkcjePlatnosci.EUR, FunkcjePlatnosci.USD, FunkcjePlatnosci.GBP, FunkcjePlatnosci.GBP)] string output
|
|---|
| 21 | )
|
|---|
| 22 | {
|
|---|
| 23 | //Arrange
|
|---|
| 24 | var funkcjePlantosi = new FunkcjePlatnosci();
|
|---|
| 25 |
|
|---|
| 26 | //Act
|
|---|
| 27 | var result = funkcjePlantosi.GetCurrency(input);
|
|---|
| 28 |
|
|---|
| 29 | //Assert
|
|---|
| 30 | Assert.That(result, Is.EqualTo(output));
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | [Test]
|
|---|
| 34 | [Category("Unit")]
|
|---|
| 35 | public void CreateAndAddNewPayment_Creates_PlatnosciEcard()
|
|---|
| 36 | {
|
|---|
| 37 | //Arrange
|
|---|
| 38 | var idFaktury = 123;
|
|---|
| 39 | var repPayment = new Repository<PlatnosciEcard>(new FakeDataContext());
|
|---|
| 40 | var funkcjePlatnosci = new FunkcjePlatnosci(repPayment, _translateManager);
|
|---|
| 41 | var invoice = _function.CreateInvoice(idFaktury, "nip", "abc/2009", 200, 2);
|
|---|
| 42 | var payer = _function.CreatePayer(idFaktury, "test", "test");
|
|---|
| 43 | var waluta = new Waluta { Amount = 200, Currency = FunkcjePlatnosci.PLN };
|
|---|
| 44 |
|
|---|
| 45 | //Act
|
|---|
| 46 | funkcjePlatnosci.CreateAndAddNewPyment(invoice, waluta, payer, "sessionId");
|
|---|
| 47 | var payment = repPayment.Find(p => p.IDFaktury == 123).SingleOrDefault();
|
|---|
| 48 |
|
|---|
| 49 | //Act
|
|---|
| 50 | Assert.That(payment.AMOUNT, Is.EqualTo(200));
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | [Test, Sequential]
|
|---|
| 54 | [Category("Unit")]
|
|---|
| 55 | public void BruttoToString_Returns_Correct_Amount(
|
|---|
| 56 | [Values(null, "", "pln", "PLN", "GBP", "gbp", "xx")] string input,
|
|---|
| 57 | [Values("100 PLN ", "100 PLN ", "100 PLN ", "100 PLN ", "100 PLN (1 GBP)", "100 PLN (1 GBP)", "100 PLN (1 XX)")] string output
|
|---|
| 58 | )
|
|---|
| 59 | {
|
|---|
| 60 | //Arrange
|
|---|
| 61 | var funkcjePlantosi = new FunkcjePlatnosci();
|
|---|
| 62 |
|
|---|
| 63 | //Act
|
|---|
| 64 | var result = funkcjePlantosi.BruttoToString(100, 1, input);
|
|---|
| 65 |
|
|---|
| 66 | //Act
|
|---|
| 67 | System.Diagnostics.Debug.WriteLine(result);
|
|---|
| 68 | Assert.That(result, Is.EqualTo(output));
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | }
|
|---|
| 72 | }
|
|---|