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