Exemple #1
0
        public void AccountTest_ThreeAccounts_ToWithdrayMoneyFromAccount_Moq(int id, string name, string surname, decimal amount, int bonus, AccountTypeDTO accountType)
        {
            // Arrange
            Mock <IBonus> mockWithraw       = new Mock <IBonus>();
            Mock <IBonus> mockReplenishment = new Mock <IBonus>();

            // Act
            mockWithraw.Setup(m => m.GetBonusPoints(It.IsAny <BankAccountDTO>(), It.IsAny <decimal>()))
            .Returns <BankAccountDTO, decimal>((account, balance) => account.BonusPointToWithdraw);

            mockReplenishment.Setup(m => m.GetBonusPoints(It.IsAny <BankAccountDTO>(), It.IsAny <decimal>()))
            .Returns <BankAccountDTO, decimal>((account, balance) => account.BonusPointToReplenishment);

            IBankAccountFactory bankAccount = new BankAccountFactory()
            {
                Withdraw      = mockWithraw.Object,
                Replenishment = mockReplenishment.Object
            };

            BankAccountDTO accountDTO = bankAccount.GetAccount(id, name, surname, amount, bonus, accountType);

            accountDTO.ReplenishmentMoney(100500);
            accountDTO.WithdrawMoney(100500);

            // Assert
            Assert.AreEqual(0, accountDTO.Amount);
        }