| 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 | 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 IncorrectUserIdentity_ReturnErrorView()
|
|---|
| 19 | {
|
|---|
| 20 | IRepository<vPlatnosciEcard> repVPayment = new Repository<vPlatnosciEcard>(new FakeDataContext());
|
|---|
| 21 | vPlatnosciEcard platnosc = _function.CreateInvoice(123, "nip1", "", 0, 0);
|
|---|
| 22 | repVPayment.Insert(platnosc);
|
|---|
| 23 |
|
|---|
| 24 | Payer payer = _function.CreatePayer(123, "test", "test");
|
|---|
| 25 |
|
|---|
| 26 | var controller = new PlatnoscController(repVPayment, null, null, _translateManager);
|
|---|
| 27 | controller.ControllerContext = _function.CreateControllerContext("nip2");
|
|---|
| 28 |
|
|---|
| 29 | var result = controller.Show(payer, "pl") as ViewResult;
|
|---|
| 30 | var error = (ErrorViewData)result.ViewData.Model;
|
|---|
| 31 |
|
|---|
| 32 | Assert.That(error.error, Is.EqualTo("weryfikacja"));
|
|---|
| 33 | Assert.That(result.ViewName, Is.EqualTo("Error1"));
|
|---|
| 34 | }
|
|---|
| 35 | [Test]
|
|---|
| 36 | [Category("Unit")]
|
|---|
| 37 | public void PaymentNotFound_ReturnErrorView()
|
|---|
| 38 | {
|
|---|
| 39 | IRepository<vPlatnosciEcard> repVPayment = new Repository<vPlatnosciEcard>(new FakeDataContext());
|
|---|
| 40 | vPlatnosciEcard platnosc = _function.CreateInvoice(12, "nip1", "", 0, 0);
|
|---|
| 41 | repVPayment.Insert(platnosc);
|
|---|
| 42 |
|
|---|
| 43 | Payer payer = _function.CreatePayer(123, "test", "test");
|
|---|
| 44 |
|
|---|
| 45 | var controller = new PlatnoscController(repVPayment, null, null, _translateManager);
|
|---|
| 46 | controller.ControllerContext = _function.CreateControllerContext("nip2");
|
|---|
| 47 |
|
|---|
| 48 | var result = controller.Show(payer, "pl") as ViewResult;
|
|---|
| 49 | var error = (ErrorViewData)result.ViewData.Model;
|
|---|
| 50 |
|
|---|
| 51 | Assert.That(error.error, Is.EqualTo("brakdanych"));
|
|---|
| 52 | Assert.That(result.ViewName, Is.EqualTo("Error1"));
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | }
|
|---|
| 56 | }
|
|---|