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