public async Task GetIncludedAccountBalanceSummary_CorrectSum() { // Arrange var accountExcluded = new Account("test", 80, isExcluded: true); var accountIncluded1 = new Account("test", 100); var accountIncluded2 = new Account("test", 120); await context.AddAsync(accountExcluded); await context.AddAsync(accountIncluded1); await context.AddAsync(accountIncluded2); await context.SaveChangesAsync(); // Act decimal result = await new GetIncludedAccountBalanceSummaryQuery.Handler(contextAdapter) .Handle(new GetIncludedAccountBalanceSummaryQuery(), default); // Assert result.Should().Be(220); }
public async Task GetIncludedAccountBalanceSummary_CorrectSum() { // Arrange var systemDateHelper = Substitute.For <ISystemDateHelper>(); systemDateHelper.Today.Returns(new DateTime(2020, 09, 05)); var accountIncluded = new Account("test", 100); var payment = new Payment(new DateTime(2020, 09, 25), 50, PaymentType.Expense, accountIncluded); await context.AddAsync(accountIncluded); await context.AddAsync(payment); await context.SaveChangesAsync(); // Act decimal result = await new GetTotalEndOfMonthBalanceQuery.Handler(contextAdapterMock, systemDateHelper).Handle( new GetTotalEndOfMonthBalanceQuery(), default); // Assert result.Should().Be(50); }
public async Task UpdatePayment_PaymentFound() { // Arrange var payment1 = new Payment(DateTime.Now, 20, PaymentType.Expense, new Account("test", 80)); await context.AddAsync(payment1); await context.SaveChangesAsync(); payment1.UpdatePayment(payment1.Date, 100, payment1.Type, payment1.ChargedAccount); // Act await new UpdatePaymentCommand.Handler(contextAdapterMock.Object) .Handle(new UpdatePaymentCommand(payment1.Id, payment1.Date, payment1.Amount, payment1.IsCleared, payment1.Type, payment1.Note, payment1.IsRecurring, payment1.Category != null ? payment1.Category.Id : 0, payment1.ChargedAccount != null ? payment1.ChargedAccount.Id : 0, payment1.TargetAccount != null ? payment1.TargetAccount.Id : 0, false, null, null, null), default); // Assert (await context.Payments.FindAsync(payment1.Id)).Amount.ShouldEqual(payment1.Amount); }
public Task SaveAsync() => _context.SaveChangesAsync();
public async Task<int> Add(UserTask task) { _context.Add(task); return await _context.SaveChangesAsync(); }