示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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));
        }
示例#4
0
        public void WithdrawAmount_GivenInvalidAmount_ThrowException()
        {
            var sut = new AccountBuilder().WithBalance(0m).Build();

            Assert.Throws <InvalidOperationException>(() => sut.WithdrawAmount(0.01m));
        }