Exemple #1
0
        public void When_AddInvoice_AddedToDatabase()
        {
            var invoice = new Invoice()
            {
                InvoiceNumber = "abcdef"
            };
            var ledger       = new Ledger(ledgerRepository);
            var savedInvoice = ledger.AddInvoice(invoice);

            savedInvoice.Id.Should().NotBe(ObjectId.Empty);
        }
Exemple #2
0
        public void When_AddInvoice_ShouldBeAbleToSearchForit()
        {
            var invoice = new Invoice()
            {
                InvoiceNumber = "abcdef"
            };
            var ledger          = new Ledger(ledgerRepository);
            var savedInvoice    = ledger.AddInvoice(invoice);
            var searchedInvoice = ledger.GetInvoiceById(savedInvoice.Id);

            searchedInvoice.Id.Should().Be(savedInvoice.Id);
        }
Exemple #3
0
        public void When_AddInvoice_Then_ItShouldBeAddedToLedger()
        {
            var ledgerRepositoryMock = new Mock <ILedgerRepository>();
            var invoice = new Invoice();

            ledgerRepositoryMock.Setup(lr => lr.AddInvoice(invoice)).Returns(invoice);
            var ledger       = new Ledger(ledgerRepositoryMock.Object);
            var addedInvoice = (ledger.AddInvoice(invoice));

            addedInvoice.Should().Be(invoice);
            ledgerRepositoryMock.Verify();
        }
Exemple #4
0
        public void When_AddInvoice_Then_InvoiceStoredInPersistanceLayer()
        {
            var ledgerRepositoryMoq = new Mock <ILedgerRepository>();
            var id      = ObjectId.GenerateNewId();
            var invoice = new Invoice(id)
            {
                InvoiceNumber = "abc/2018"
            };

            ledgerRepositoryMoq.Setup(foo => foo.AddInvoice(It.IsAny <Invoice>())).Returns(invoice);
            var ledger          = new Ledger(ledgerRepositoryMoq.Object);
            var returnedInvoice = ledger.AddInvoice(invoice);

            returnedInvoice.Id.Should().Be(id);
            ledgerRepositoryMoq.VerifyAll();
        }