using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Platnosci.Models;
using Platnosci.Core.Linq;
using Platnosci.Core.Interface;


namespace Platnosci.Tests.Web
{
    [TestFixture]
    class FunkcjePlatnosciTests
    {
        private readonly Function _function = new Function();
        private readonly ITranslateManager _translateManager = new FakeTranslation();

        [Test, Sequential]
        [Category("Unit")]
        public void GetCurrency_Returns_PLN_When_Passing_Null(
            [Values(null, "", "eur", "usd", "gbp", "GBP")] string input,
            [Values(FunkcjePlatnosci.PLN, FunkcjePlatnosci.PLN, FunkcjePlatnosci.EUR, FunkcjePlatnosci.USD, FunkcjePlatnosci.GBP, FunkcjePlatnosci.GBP)] string output
            )
        {
            var funkcjePlantosi = new FunkcjePlatnosci();
            var result = funkcjePlantosi.GetCurrency(input);
            Assert.That(result, Is.EqualTo(output));
        }
        [Test]
        [Category("Unit")]
        public void TestMethodCreateAndAddNewPaymentOk()
        {
            var idFaktury = 123;
            var repPayment = new Repository<PlatnosciEcard>(new FakeDataContext());
            var funkcjePlatnosci = new FunkcjePlatnosci(repPayment, _translateManager);
            var invoice = _function.CreateInvoice(idFaktury, "nip", "abc/2009", 200, 2);
            var payer = _function.CreatePayer(idFaktury, "test", "test");
            var waluta = new Waluta { Amount = 200, Currency = FunkcjePlatnosci.PLN };
            var result = funkcjePlatnosci.CreateAndAddNewPyment(invoice, waluta, payer, "sessionId");

            var payment = repPayment.Find(p => p.IDFaktury == 123).SingleOrDefault();
            Assert.That(payment.IDFaktury, Is.EqualTo(idFaktury));
        }
    }
}
