﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Platnosci.Core.Linq;
using Platnosci.Core.Interface;

namespace Platnosci.Tests.Web
{
    [TestFixture]
    class TestMethods
    {
        private string testNip1 = "12345";
        private int testIdFaktury = 1000;

        private Function _f = new Function();

        [Test]
        [Category("Unit")]
        public void TestFindInvoiceByNumber()
        {
            FakeDataContext fake = new FakeDataContext();
            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);

            vPlatnosciEcard platnosc = new vPlatnosciEcard();
            platnosc = _rep.FindInvoiceById(1).SingleOrDefault();
            Assert.That(platnosc.Faktura_Numer, Is.EqualTo("1"));
        }
        [Test]
        [Category("Unit")]
        public void TestInsertMethodForPayment()
        {
            FakeDataContext fake = new FakeDataContext();
            IRepository<vPlatnosciEcard> _rep = new Repository<vPlatnosciEcard>(fake);

            vPlatnosciEcard platnosc = _f.createPayment(testIdFaktury, testNip1, "", 0, 0);
            _rep.Insert(platnosc);

            vPlatnosciEcard pl = _rep.FindInvoiceById(testIdFaktury).SingleOrDefault();
            Assert.That(pl.nip, Is.EqualTo(testNip1));
        }
    }
}
