| [952] | 1 | using System;
|
|---|
| 2 | using NUnit.Framework;
|
|---|
| [919] | 3 | using Platnosci.Core.Linq;
|
|---|
| 4 | using Platnosci.Core.Interface;
|
|---|
| 5 | using Platnosci.Controllers;
|
|---|
| 6 | using Platnosci.Models;
|
|---|
| 7 | using System.Web.Mvc;
|
|---|
| 8 |
|
|---|
| 9 | namespace Platnosci.Tests.Web
|
|---|
| 10 | {
|
|---|
| 11 | [TestFixture]
|
|---|
| 12 | class MerchantControllerTests
|
|---|
| 13 | {
|
|---|
| [931] | 14 | private readonly Function _function = new Function();
|
|---|
| 15 | private readonly ITranslateManager _translateManager = new FakeTranslation();
|
|---|
| [919] | 16 |
|
|---|
| 17 | [Test]
|
|---|
| 18 | [Category("Unit")]
|
|---|
| [960] | 19 | public void Merchant_Action_Returns_Error_When_Passing_Incorrect_User_Identity()
|
|---|
| [919] | 20 | {
|
|---|
| [960] | 21 | //Arrange
|
|---|
| [919] | 22 | IRepository<vPlatnosciEcard> repVPayment = new Repository<vPlatnosciEcard>(new FakeDataContext());
|
|---|
| [931] | 23 | vPlatnosciEcard platnosc = _function.CreateInvoice(123, "nip1", "", 0, 0);
|
|---|
| [919] | 24 | repVPayment.Insert(platnosc);
|
|---|
| [957] | 25 |
|
|---|
| [931] | 26 | Payer payer = _function.CreatePayer(123, "test", "test");
|
|---|
| [957] | 27 |
|
|---|
| 28 | var controller = new MerchantController(repVPayment, null, _translateManager);
|
|---|
| [931] | 29 | controller.ControllerContext = _function.CreateControllerContext("nip2");
|
|---|
| [919] | 30 |
|
|---|
| [960] | 31 | //Act
|
|---|
| [957] | 32 | var result = controller.Merchant(payer, "pl") as ViewResult;
|
|---|
| [919] | 33 | var error = (ErrorViewData)result.ViewData.Model;
|
|---|
| 34 |
|
|---|
| [960] | 35 | //Assert
|
|---|
| [933] | 36 | Assert.That(error.Error, Is.EqualTo("weryfikacja"));
|
|---|
| [919] | 37 | Assert.That(result.ViewName, Is.EqualTo("Error1"));
|
|---|
| 38 | }
|
|---|
| [960] | 39 |
|
|---|
| [919] | 40 | [Test]
|
|---|
| 41 | [Category("Unit")]
|
|---|
| [963] | 42 | public void Merchant_Action_Returns_Error_When_Payment_Is_Not_Found()
|
|---|
| [919] | 43 | {
|
|---|
| [963] | 44 | //Arrange
|
|---|
| [919] | 45 | IRepository<vPlatnosciEcard> repVPayment = new Repository<vPlatnosciEcard>(new FakeDataContext());
|
|---|
| [931] | 46 | vPlatnosciEcard platnosc = _function.CreateInvoice(12, "nip1", "", 0, 0);
|
|---|
| [919] | 47 | repVPayment.Insert(platnosc);
|
|---|
| 48 |
|
|---|
| [931] | 49 | Payer payer = _function.CreatePayer(123, "test", "test");
|
|---|
| [919] | 50 |
|
|---|
| [957] | 51 | var controller = new MerchantController(repVPayment, null, _translateManager);
|
|---|
| [931] | 52 | controller.ControllerContext = _function.CreateControllerContext("nip2");
|
|---|
| [919] | 53 |
|
|---|
| [963] | 54 | //Act
|
|---|
| [957] | 55 | var result = controller.Merchant(payer, "pl") as ViewResult;
|
|---|
| [919] | 56 | var error = (ErrorViewData)result.ViewData.Model;
|
|---|
| 57 |
|
|---|
| [963] | 58 | //Assert
|
|---|
| [933] | 59 | Assert.That(error.Error, Is.EqualTo("brakdanych"));
|
|---|
| [919] | 60 | Assert.That(result.ViewName, Is.EqualTo("Error1"));
|
|---|
| 61 | }
|
|---|
| [963] | 62 |
|
|---|
| [919] | 63 | }
|
|---|
| 64 | }
|
|---|