Exemplo n.º 1
0
        public void CaseTwo()
        {
            IPerson person = new Person(
                "Fred",
                new List <IWallet>()
            {
                new Wallet("Wallet1", new List <Card>()
                {
                    new VisaCard("Visa1", 100, .1),
                    new DiscoverCard("DiscoverCard1", 100, .1)
                }),
                new Wallet("Wallet2", new List <Card>()
                {
                    new MasterCard("MasterCard1", 100, .1)
                })
            }
                );

            IPersonInterestCalculator interest = new FullPersonInterestCalculator(new SimpleInterestCalculator());

            IPerson newPerson = interest.ComputeTotalInterestForPerson(person, 1);

            Assert.That(newPerson.Interest, Is.EqualTo(30));
            Assert.That(newPerson.Wallets[0].Interest, Is.EqualTo(20));
            Assert.That(newPerson.Wallets[1].Interest, Is.EqualTo(10));
        }
        public void When_SimpleInterestIs10_On1Cards_InterestIs10()
        {
            Card visaCard = new VisaCard("Visa1", 100, .1);
            FullPersonInterestCalculator interestCalculator = new FullPersonInterestCalculator(new SimpleInterestCalculator());

            Card newVisa = interestCalculator.ComputeTotalInterestForCard(visaCard, 1);

            Assert.That(newVisa.Interest, Is.EqualTo(10).Within(.1));
        }
        public void When_SimpleInterestIs10_On3Cards_WalletTotalIs30()
        {
            IWallet wallet = new Wallet("Wallet1", new List <Card>
            {
                new VisaCard("Visa1", 100, .1),
                new MasterCard("MasterCard1", 100, .1),
                new DiscoverCard("DiscoverCard1", 100, .1)
            });
            FullPersonInterestCalculator interestCalculator = new FullPersonInterestCalculator(new SimpleInterestCalculator());

            IWallet newWallet = interestCalculator.ComputeTotalInterestForWallet(wallet, 1);

            Assert.That(newWallet.Interest, Is.EqualTo(30).Within(.1));
        }
        public void When_SimpleInterestIs10_On3Cards_TotalIs30()
        {
            IPerson person = new Person(
                "Fred",
                new List <IWallet> {
                new Wallet("Wallet1", new List <Card>
                {
                    new VisaCard("Visa1", 100, .1),
                    new MasterCard("MasterCard1", 100, .1),
                    new DiscoverCard("DiscoverCard1", 100, .1)
                })
            });
            FullPersonInterestCalculator interestCalculator = new FullPersonInterestCalculator(new SimpleInterestCalculator());

            var newperson = interestCalculator.ComputeTotalInterestForPerson(person, 1);

            Assert.That(newperson.Interest, Is.EqualTo(30).Within(.1));
        }
Exemplo n.º 5
0
        public void CaseThree()
        {
            IPerson fred = new Person(
                "Fred",
                new List <IWallet>()
            {
                new Wallet("Wallet1", new List <Card>()
                {
                    new VisaCard("Visa1", 100, .1),
                    new MasterCard("MasterCard1", 100, .1)
                })
            }
                );

            IPerson george = new Person(
                "George",
                new List <IWallet>()
            {
                new Wallet("Wallet1", new List <Card>()
                {
                    new VisaCard("Visa1", 100, .1),
                    new MasterCard("MasterCard1", 100, .1)
                }),
            }
                );
            IPersonInterestCalculator interest = new FullPersonInterestCalculator(new SimpleInterestCalculator());

            IPerson newFred   = interest.ComputeTotalInterestForPerson(fred, 1);
            IPerson newGeorge = interest.ComputeTotalInterestForPerson(george, 1);

            Assert.That(newFred.Interest, Is.EqualTo(20));
            Assert.That(newFred.Wallets[0].Interest, Is.EqualTo(20));

            Assert.That(newGeorge.Interest, Is.EqualTo(20));
            Assert.That(newGeorge.Wallets[0].Interest, Is.EqualTo(20));
        }