using JamesKovacs.IoCArticle.DiyContainer.Domain;
using JamesKovacs.IoCArticle.DiyContainer.Infrastructure.Container;
using JamesKovacs.IoCArticle.DiyContainer.Repositories;
using JamesKovacs.IoCArticle.DiyContainer.Services;
using MbUnit.Framework;

namespace JamesKovacs.IoCArticle.DiyContainer.Tests.Integration.Services {
    [TestFixture]
    public class InvoiceServiceTests {
        [SetUp]
        public void SetUp() {
            SimpleDependencyResolver resolver = new SimpleDependencyResolver();
            resolver.Register<IAuthorizationService>(new AuthorizationService());
            resolver.Register<IInvoiceValidator>(new InvoiceValidator());
            resolver.Register<IInvoiceRepository>(new InvoiceRepository());
            IoC.Initialize(resolver);
        }

        [TearDown]
        public void TearDown() {
            IoC.Initialize(null);
        }

        [Test]
        public void CanSubmitNewInvoice() {
            Invoice invoice = new Invoice();
            IInvoiceService service = new InvoiceService();
            ValidationResults validationResults = service.Submit(invoice);
            Assert.IsTrue(validationResults.IsValid);
        }
    }
}