public void WithdrawAmount_GivenValidAmount_UpdateBalanceAndWithdrawnAmounts() { var sut = new AccountBuilder().WithBalance(0.02m).Build(); sut.WithdrawAmount(0.01m); Assert.Equal(0.01m, sut.Balance); Assert.Equal(-0.01m, sut.Withdrawn); }
public void WithdrawAmount_GivenBalanceIsAboveLowBalanceThreshold_DoNotNotifyUser() { var notificationServiceMock = new Mock <INotificationService>(); var user = new User(notificationServiceMock.Object); var sut = new AccountBuilder() .WithBalance(Account.LowBalanceThreshold + 0.01m) .WithUser(user) .Build(); sut.WithdrawAmount(0.01m); notificationServiceMock.Verify(service => service.NotifyFundsLow(It.IsAny <string>()), Times.Never); }
public void WithdrawAmount_GivenBalanceIsBelowLowBalanceThreshold_NotifyUser() { var notificationServiceMock = new Mock <INotificationService>(); var user = new User(notificationServiceMock.Object); user.Email = "*****@*****.**"; var sut = new AccountBuilder() .WithBalance(0.02m) .WithUser(user) .Build(); sut.WithdrawAmount(0.01m); notificationServiceMock.Verify(service => service.NotifyFundsLow(user.Email)); }
public void WithdrawAmount_GivenInvalidAmount_ThrowException() { var sut = new AccountBuilder().WithBalance(0m).Build(); Assert.Throws <InvalidOperationException>(() => sut.WithdrawAmount(0.01m)); }