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