public async Task SaveFinancialTransaction_Failure_NoParentLedger() { var ledgerId = 666; var model = new Domain.Models.Transaction { Description = "Test", TransactionDate = DateTime.UtcNow, AccountingEntries = new List <Domain.Models.AccountingEntry> { new Domain.Models.AccountingEntry { Amount = 100, Side = Domain.Models.AccountingEntry.EntrySide.Credit }, new Domain.Models.AccountingEntry { Amount = 100, Side = Domain.Models.AccountingEntry.EntrySide.Debit } } }; var request = new SaveTransactionRequest(ledgerId, model); var handler = new SaveTransactionRequestHandler(_trackingContext, Mapper.Instance); var result = await handler.Handle(request, default(CancellationToken)); }
public async Task SaveTransaction_Success() { var expectedResultCount = 1; var dataGenerationResult1 = _trackingContext.AddTestData <Domain.Entities.Ledger>(expectedResultCount); var dataGenerationResult2 = _trackingContext.AddTestData <Domain.Entities.Transaction>(expectedResultCount); Assert.IsTrue(dataGenerationResult1.Item1); Assert.IsTrue(dataGenerationResult2.Item1); var ledgerId = dataGenerationResult1.Item2[0]; var model = new Domain.Models.Transaction { Description = "Test", TransactionDate = DateTime.UtcNow, AccountingEntries = new List <Domain.Models.AccountingEntry> { new Domain.Models.AccountingEntry { Amount = 100, Side = Domain.Models.AccountingEntry.EntrySide.Credit, AccountId = 1 }, new Domain.Models.AccountingEntry { Amount = 100, Side = Domain.Models.AccountingEntry.EntrySide.Debit, AccountId = 1 } } }; var request = new SaveTransactionRequest(ledgerId, model); var handler = new SaveTransactionRequestHandler(_trackingContext, Mapper.Instance); var result = await handler.Handle(request, default(CancellationToken)); Assert.AreEqual(result, Unit.Value); }