Esempio n. 1
0
        public void TestCalcProfit()
        {
            PriceDeterminator priceCalculator   = new PriceDeterminator();
            decimal           purchasePrice     = 41186m;
            decimal           realPurchasePrice = 45344m;

            Assert.AreEqual(priceCalculator.CalcValGivenCutoff(purchasePrice, realPurchasePrice), 40809.6);
        }
Esempio n. 2
0
        public void TestCalcCollisions()
        {
            PriceDeterminator priceCalculator = new PriceDeterminator();
            byte    collisions    = 3;
            decimal purchasePrice = 29786m;

            Assert.AreEqual(priceCalculator.CalcValGivenColls(collisions, purchasePrice), 27998.84);
        }
Esempio n. 3
0
        public void TestCalcReliability()
        {
            PriceDeterminator priceCalculator = new PriceDeterminator();
            string            make            = "Toyota";
            decimal           purchasePrice   = 39786m;

            Assert.AreEqual(priceCalculator.CalcValGivenReliable(make, purchasePrice), 41775.30);
        }
Esempio n. 4
0
        public void TestCalcMileageValue()
        {
            PriceDeterminator priceCalculator = new PriceDeterminator();
            int     mileage       = 12354;
            decimal purchasePrice = 34000m;

            Assert.AreEqual(priceCalculator.CalcValGivenMiles(mileage, purchasePrice), 33184);
        }
Esempio n. 5
0
        public void TestCalcPrevOwner()
        {
            PriceDeterminator priceCalculator = new PriceDeterminator();
            byte    prevOwners    = 3;
            decimal purchasePrice = 25034m;

            Assert.AreEqual(priceCalculator.CalcValGivenOwners(prevOwners, purchasePrice), 18775.50);
        }
Esempio n. 6
0
        public void TestCalcAgeValue()
        {
            PriceDeterminator priceCalculator = new PriceDeterminator();
            byte    ageInMonths   = 12;
            decimal purchasePrice = 25000m;

            Assert.AreEqual(priceCalculator.CalcValGivenAge(ageInMonths, purchasePrice), 23500);
            ageInMonths = 120;
            Assert.AreEqual(priceCalculator.CalcValGivenAge(ageInMonths, purchasePrice), 10125);
        }
Esempio n. 7
0
 private static void AssertCarValue(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);
 }
Esempio n. 8
0
        private static void AssertCarValue(decimal expectValue, decimal purchaseValue, int ageInMonths, int numberOfMiles, int numberOfPreviousOwners, int numberOfCollisions, string make)
        {
            var car = new Car
            {
                AgeInMonths            = ageInMonths,
                NumberOfCollisions     = numberOfCollisions,
                NumberOfMiles          = numberOfMiles,
                NumberOfPreviousOwners = numberOfPreviousOwners,
                PurchaseValue          = purchaseValue,
                Make = make
            };

            var priceDeterminator = new PriceDeterminator();
            var carPrice          = priceDeterminator.DetermineCarPrice(car);

            Assert.AreEqual(expectValue, carPrice);
        }
        private static void AssertCarValue(decimal expectValue, decimal purchaseValue,
                                           int ageInMonths, int numberOfMiles, int numberOfPreviousOwners, int
                                           numberOfCollisions, string make)
        {
            Car car = new Car
            {
                AgeInMonths            = ageInMonths,
                NumberOfCollisions     = numberOfCollisions,
                NumberOfMiles          = numberOfMiles,
                NumberOfPreviousOwners = numberOfPreviousOwners,
                PurchaseValue          = purchaseValue,
                Make = make
            };
            PriceDeterminator priceDeterminator = new PriceDeterminator();
            var    carPrice = priceDeterminator.DetermineCarPrice(car);
            string msg      = $"expected value:{expectValue} and calculated value: {carPrice}";

            Console.WriteLine(msg);
            printMsg(msg);
            Assert.AreEqual(expectValue, carPrice);
        }
Esempio n. 10
0
        private static void AssertCarValue(decimal expectValue, decimal purchaseValue,
                                           int ageInMonths, int numberOfMiles, int numberOfPreviousOwners, int
                                           numberOfCollisions, int testNum)
        {
            Car car = new Car
            {
                AgeInMonths            = ageInMonths,
                NumberOfCollisions     = numberOfCollisions,
                NumberOfMiles          = numberOfMiles,
                NumberOfPreviousOwners = numberOfPreviousOwners,
                PurchaseValue          = purchaseValue
            };
            PriceDeterminator priceDeterminator = new PriceDeterminator();
            var carPrice = priceDeterminator.DetermineCarPrice(car, testNum);

            var difference = expectValue - carPrice;

            Console.WriteLine("{0}", difference == 0 ? "PASS" : "FAIL");
            Console.WriteLine("Expected Value {0}, ActualValue {1}", expectValue, carPrice);
            Console.WriteLine("Off by: {0}", difference);
            //Assert.AreEqual(expectValue, carPrice);
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
        public void should_calculate_collision_reduction(int collisons, decimal price, decimal expected)
        {
            var actual = new PriceDeterminator().ApplyCollisionReduction(collisons, price);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 13
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);
        }
Esempio n. 14
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);
        }