Пример #1
0
        public static decimal GetCarValue(decimal purchaseValue, int months, int miles, int owners, int collisions)
        {
            Car car = new Car
            {
                AgeInMonths            = months,
                NumberOfCollisions     = collisions,
                NumberOfMiles          = miles,
                NumberOfPreviousOwners = owners,
                PurchaseValue          = purchaseValue
            };
            PriceDeterminator priceDeterminator = new PriceDeterminator();
            var carPrice = priceDeterminator.DetermineCarPrice(car);

            return(carPrice);
        }
        private static void AssertCarValue(decimal expectValue, decimal purchaseValue, int ageInMonths, int numberOfMiles, int numberOfPreviousOwners, int numberOfCollisions)
        {
            var car = new Car
            {
                AgeInMonths            = ageInMonths,
                NumberOfCollisions     = numberOfCollisions,
                NumberOfMiles          = numberOfMiles,
                NumberOfPreviousOwners = numberOfPreviousOwners,
                PurchaseValue          = purchaseValue
            };
            var     priceDeterminator = new PriceDeterminator();
            decimal carPrice          = priceDeterminator.DetermineCarPrice(car);

            Assert.AreEqual(expectValue, carPrice);
        }
Пример #3
0
        public void DetermineCarPrice_Always_Return_Expected_Value(decimal expectValue, decimal purchaseValue, int ageInMonths, int numberOfMiles, int numberOfPreviousOwners, int numberOfCollisions)
        {
            Car car = new Car
            {
                PurchaseValue          = purchaseValue,
                AgeInMonths            = ageInMonths,
                NumberOfMiles          = numberOfMiles,
                NumberOfPreviousOwners = numberOfPreviousOwners,
                NumberOfCollisions     = numberOfCollisions,
            };

            PriceDeterminator priceDeterminator = new PriceDeterminator();
            decimal           result            = priceDeterminator.DetermineCarPrice(car);

            Assert.AreEqual(expectValue, result);
        }
Пример #4
0
        private static void DisplayCarValue(decimal expectValue, decimal purchaseValue,
                                            int ageInMonths, int numberOfMiles, int numberOfPreviousOwners, int
                                            numberOfCollisions)
        {
            Car car = new Car
            {
                AgeInMonths            = ageInMonths,
                NumberOfCollisions     = numberOfCollisions,
                NumberOfMiles          = numberOfMiles,
                NumberOfPreviousOwners = numberOfPreviousOwners,
                PurchaseValue          = purchaseValue
            };
            PriceDeterminator priceDeterminator = new PriceDeterminator();
            var carPrice = priceDeterminator.DetermineCarPrice(car);

            Console.WriteLine("Expected Value: " + expectValue.ToString() + " Actual Value: " + carPrice.ToString());
        }
Пример #5
0
        public void Should_calculate_previous_owners_bonus(int owners, decimal price, decimal expected)
        {
            var actual = new PriceDeterminator().ApplyPreviousOwnersBonus(owners, price);

            Assert.AreEqual(expected, actual);
        }
Пример #6
0
        public void Should_calculate_collision_reduction(int collisons, decimal price, decimal expected)
        {
            var actual = new PriceDeterminator().ApplyCollisionReduction(collisons, price);

            Assert.AreEqual(expected, actual);
        }
Пример #7
0
        public void Should_calculate_miles_price_reduction(int miles, decimal price, decimal expected)
        {
            var actual = new PriceDeterminator().ApplyMilesReduction(miles, price);

            Assert.AreEqual(expected, actual);
        }
Пример #8
0
        public void Should_calculate_age_price_reduction(int age, decimal price, decimal expected)
        {
            var actual = new PriceDeterminator().ApplyAgeReduction(age, price);

            Assert.AreEqual(expected, actual);
        }