Ejemplo n.º 1
0
        public void PayInAmount_GivenValidAmount_UpdateBalanceAndPaidInAmount()
        {
            var sut = new AccountBuilder().WithBalance(0).Build();

            sut.PayInAmount(0.01m);

            Assert.Equal(0.01m, sut.Balance);
            Assert.Equal(0.01m, sut.PaidIn);
        }
Ejemplo n.º 2
0
        public void PayInAmount_GivenPayInLimitDifferenceThresholdNotExceeded_DoNotNotifyUser()
        {
            var notificationServiceMock = new Mock <INotificationService>();
            var user = new User(notificationServiceMock.Object);

            var sut = new AccountBuilder()
                      .WithUser(user)
                      .WithPaidIn(Account.PayInLimit - Account.PayInLimitDifferenceThreshold - 0.01m)
                      .Build();

            sut.PayInAmount(0.01m);

            notificationServiceMock.Verify(service => service.NotifyApproachingPayInLimit(It.IsAny <string>()), Times.Never);
        }
Ejemplo n.º 3
0
        public void PayInAmount_GivenPayInLimitDifferenceThresholdExceeded_NotifyUser()
        {
            var notificationServiceMock = new Mock <INotificationService>();
            var user = new User(notificationServiceMock.Object);

            user.Email = "*****@*****.**";

            var sut = new AccountBuilder()
                      .WithUser(user)
                      .WithPaidIn(Account.PayInLimit - Account.PayInLimitDifferenceThreshold)
                      .Build();

            sut.PayInAmount(0.01m);

            notificationServiceMock.Verify(service => service.NotifyApproachingPayInLimit(user.Email));
        }
Ejemplo n.º 4
0
        public void PayInAmount_GivenInvalidAmount_ThrowException()
        {
            var sut = new AccountBuilder().WithPaidIn(Account.PayInLimit).Build();

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