Beispiel #1
0
        public void TestConstructor()
        {
            var value    = 1;
            var currency = new DummyCurrency();
            var price    = new Price <DummyCurrency>(value, currency);

            Assert.Equal(value, price.Value);
            Assert.Equal(currency, price.Currency);
        }
Beispiel #2
0
        public void TestAdd()
        {
            var currency = new DummyCurrency();
            var a        = new Price <DummyCurrency>(1, currency);
            var b        = new Price <DummyCurrency>(2, currency);

            Assert.Equal(3, a.Add(b).Value);
            Assert.Equal(currency, a.Add(b).Currency);
            Assert.Equal(3, b.Add(a).Value);
            Assert.Equal(3, (a + b).Value);
            Assert.Equal(3, (b + a).Value);
        }
        public void TestSpecializedEquipment(int oneTime, int premiumDaily, int regularDaily, int days, int expected)
        {
            var specialized = new SpecializedEquipment();

            Assert.Equal(1, specialized.LoyaltyPoints);

            var prices = new RentalFees <DummyCurrency>(
                DummyCurrency.CreatePrice(oneTime),
                DummyCurrency.CreatePrice(premiumDaily),
                DummyCurrency.CreatePrice(regularDaily));
            var expectedPrice = DummyCurrency.CreatePrice(expected);

            Assert.Equal(expectedPrice, specialized.CalculatePrice(prices, days));
        }
        public void TestHeavyEquipment(int oneTime, int premiumDaily, int regularDaily, int days, int expected)
        {
            var heavy = new HeavyEquipment();

            Assert.Equal(2, heavy.LoyaltyPoints);

            var prices = new RentalFees <DummyCurrency>(
                DummyCurrency.CreatePrice(oneTime),
                DummyCurrency.CreatePrice(premiumDaily),
                DummyCurrency.CreatePrice(regularDaily));
            var expectedPrice = DummyCurrency.CreatePrice(expected);

            Assert.Equal(expectedPrice, heavy.CalculatePrice(prices, days));
        }