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