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