public void Fail_Null_CreditCard() { var calculator = new SimpleInterestCalculator(CardRepo); var nullCards = new Person { Wallets = new List <Wallet> { new Wallet { Cards = new List <CreditCard> { null, }, } }, }; Assert.Throws( Is.TypeOf <ArgumentException>() .And.Message.EqualTo("Cannot have null credit cards"), () => { var calculation = calculator.Calculate(nullCards); }); }
public void Fail_Missing_InterestRate() { var calculator = new SimpleInterestCalculator(CardRepo_Incomplete); var person = new Person { Wallets = new List <Wallet> { new Wallet { Cards = new List <CreditCard> { CreditCardType.MasterCard, }, } }, }; Assert.Throws( Is.TypeOf <ArgumentException>() .And.Message.EqualTo("Interest rate(s) do not exist for: MasterCard"), () => { var calculation = calculator.Calculate(person); }); }
public void Calculate_ForPerson(int personId, decimal interestRate) { var person = GetPerson(personId); var calculation = SimpleInterestCalculator.Calculate(person); Assert.AreEqual(calculation, interestRate); }
public void Calculate_ByWallet_(int walletId, decimal interestRate) { var wallet = GetWallet(Person1, walletId); Assert.IsNotNull(wallet); var calculation = SimpleInterestCalculator.Calculate(wallet); Assert.AreEqual(calculation, interestRate); }
public void Fail_Null_Resolvers() { var calculator = new SimpleInterestCalculator(CardRepo); Assert.Throws( Is.TypeOf <ArgumentNullException>() .And.Message.EqualTo("Value cannot be null. (Parameter 'resolvers')"), () => { var calculation = calculator.Calculate(null); }); }
public void Calculate_ByCard_(CreditCardType cardType, decimal interestRate) { Assert.IsNotNull(Wallet1); Assert.AreNotEqual(cardType, CreditCardType.Unknown); var creditCard = GetCard(Wallet1, cardType); Assert.IsNotNull(creditCard); var calculation = SimpleInterestCalculator.Calculate(creditCard); Assert.AreEqual(calculation, interestRate); }
public void Fail_Null_CardRepo() { var calculator = new SimpleInterestCalculator(null); var validData = TestDataFactory.GetData(1).people.ToArray(); Assert.Throws( Is.TypeOf <NullReferenceException>() .And.Message.EqualTo("CardRepo is null"), () => { var calculation = calculator.Calculate(validData); }); }
public void Calculate_ForPerson() { var calculation = SimpleInterestCalculator.Calculate(Person1); Assert.AreEqual(calculation, 16.0M); }