public void OnePersonOneWalletThreeCards()
        {
            var card1 = new CreditCard(CreditCardType.Visa);
            var card2 = new CreditCard(CreditCardType.Master);
            var card3 = new CreditCard(CreditCardType.Discover);

            card1.Balance = 100;
            card2.Balance = 100;
            card3.Balance = 100;

            var wallet = new Wallet {
                Cards = new List <CreditCard> {
                    card1, card2, card3
                }
            };
            var person = new Person {
                Wallets = new List <Wallet> {
                    wallet
                }
            };

            var interest1 = _cardCalculator.GetInterest(card1);
            var interest2 = _cardCalculator.GetInterest(card2);
            var interest3 = _cardCalculator.GetInterest(card3);

            var personInterest = _personCalculator.GetInterest(person);

            Assert.AreEqual(10, interest1);
            Assert.AreEqual(5, interest2);
            Assert.AreEqual(1, interest3);

            Assert.AreEqual(16, personInterest);
        }
Esempio n. 2
0
        public double GetInterest(Wallet wallet)
        {
            if (wallet == null)
            {
                return(0);
            }
            if (wallet.Cards == null || !wallet.Cards.Any())
            {
                return(0);
            }

            return(wallet.Cards.Select(x => _calculator.GetInterest(x)).Sum());
        }