public void Post_calls_with_not_existent_account_fails() { var entityUnderTest = new JournalEntriesController(_journalEntryGroupRepository, _accountRepository); var result = entityUnderTest.Post(new List <JournalEntryViewModel> { new JournalEntryViewModel { Account = "420000000", Credit = 1000, Remarks = "HELLO THERE" }, new JournalEntryViewModel { Account = "527000001", Debit = 1000, Remarks = "GENERAL KENOBI" } }); result.Should().BeOfType <BadRequestObjectResult>(); _journalEntryGroupRepository.DidNotReceive().InsertEntries(Arg.Any <IEnumerable <LedgerEntry> >()); }
public void Post_calls_ledger_repository_with_entries() { var entityUnderTest = new JournalEntriesController(_journalEntryGroupRepository, _accountRepository); var result = entityUnderTest.Post(new List <JournalEntryViewModel> { new JournalEntryViewModel { Account = "420000000", Credit = 1000, Remarks = "HELLO THERE" }, new JournalEntryViewModel { Account = "527000000", Debit = 1000, Remarks = "GENERAL KENOBI" } }); result.Should().BeOfType <OkResult>(); _journalEntryGroupRepository.Received(1).InsertEntries(Arg.Is <IEnumerable <LedgerEntry> >(x => ExpectedCredit(x))); _journalEntryGroupRepository.Received(1).InsertEntries(Arg.Is <IEnumerable <LedgerEntry> >(x => ExpectedDebit(x))); }