public void it_can_reduce_boilerplate(WithdrawlFeature sut, Mock <IAccountRepository> accountRepository, Account account, decimal withdrawlAmount)
        {
            accountRepository.Setup(x => x.GetAccountById(It.Is <Guid>(y => y == account.Id))).Returns(account);

            sut.Execute(account, withdrawlAmount, accountRepository.Object);

            accountRepository.Verify(x => x.Update(It.Is <Account>(y => y.Id == account.Id)));
        }
示例#2
0
        public void it_can_capture_updated_value()
        {
            var accountRepository = new Mock <IAccountRepository>();
            var account           = new Account {
                Id = Guid.NewGuid(), Balance = 50m
            };

            var sut = new WithdrawlFeature();

            accountRepository.Setup(x => x.GetAccountById(It.Is <Guid>(y => y == account.Id))).Returns(account);

            Account accountAfterTransfer = null;

            accountRepository.Setup(x => x.Update(It.Is <Account>(y => y.Id == account.Id))).Callback <Account>(z => accountAfterTransfer = z);

            sut.Execute(account, 25, accountRepository.Object);

            accountAfterTransfer.Balance.Should().Be(25);
        }