public async Task FindPaymentsPayedBy_ShouldFilterPaymentsCorrectly() { var payment1 = new PaymentBuilder("Kyle") .WithDescription("KFC") .WithPaymentLine("Eric", 10.5m) .WithPaymentLine("Kyle", 9.75m) .Build(); var payment2 = new PaymentBuilder("Stan") .WithDescription("Video Games") .WithPaymentLine("Eric", 40m) .WithPaymentLine("Stan", 40m) .Build(); await _paymentRepository.AddPaymentsAsync(payment1, payment2); var result = (await _paymentRepository.FindPaymentsPayedBy("Kyle")).ToArray(); result.Should().HaveCount(1); result[0].Should().BeEquivalentTo(payment1); }
public async Task GetUserBalanceList_WithMultiplePayments_ShouldCalculateBalancesCorrectly() { var payment1 = new PaymentBuilder("Eric") .WithPaymentLine("Eric", 10) .WithPaymentLine("Stan", 5) .WithPaymentLine("Kyle", 7.5m) .WithPaymentLine("Token", 15) .Build(); var payment2 = new PaymentBuilder("Token") .WithPaymentLine("Eric", 15) .WithPaymentLine("Token", 15) .Build(); var payment3 = new PaymentBuilder("Stan") .WithPaymentLine("Kenny", 3.33m) .WithPaymentLine("Eric", 3.33m) .WithPaymentLine("Kyle", 3.33m) .Build(); await _paymentRepository.AddPaymentsAsync(payment1, payment2, payment3); var result = (await _sut.GetUserBalanceList()).ToArray(); using (new AssertionScope()) { result.Should().HaveCount(5); result[0].User.Username.Should().Be("Eric"); result[0].Balance.Should().Be(9.17m); result[1].User.Username.Should().Be("Stan"); result[1].Balance.Should().Be(4.99m); result[2].User.Username.Should().Be("Token"); result[2].Balance.Should().Be(0); result[3].User.Username.Should().Be("Kenny"); result[3].Balance.Should().Be(-3.33m); result[4].User.Username.Should().Be("Kyle"); result[4].Balance.Should().Be(-10.83m); } }