Exemple #1
0
        static void Main(string[] args)
        {
            Fruit Apple = new Fruit("Sweet", "Ripe", "England", new DateTime(2014, 08, 06));
            Fruit Mango = new Fruit("Sweet", "Ripe", "Africa", new DateTime(2014, 08, 07));

            List<Variance> variances = Apple.DetailedCompare(Mango);

            Console.WriteLine("Comparing Apple to Mango");

            foreach (Variance item in variances)
            {
                Console.WriteLine(item.Diff);
            }

            Console.WriteLine();

            /* Output does not come out correct due to check on fruit object in fruitbasket
             * has a recursion issue due to other properties can have public properties!
             * Came accross this with DateTime in Fruit.
             * */
            FruitBasket basket1 = new FruitBasket(Apple, "LARGE", 20, 10, 20, 20, "Apples are good for you!");
            FruitBasket basket2 = new FruitBasket(Mango, "SMALL", 50, 10, 20, 20, "Mangos'R'Us");

            variances = basket1.DetailedCompare(basket2);

            foreach (Variance item in variances)
            {
                Console.WriteLine(item.Diff);
            }
        }
Exemple #2
0
        public void CompareFruitBaskets()
        {
            Fruit Apple = new Fruit("Sweet", "Ripe", "England", new DateTime(2014, 08, 06));
            Fruit Mango = new Fruit("Sweet", "Ripe", "Africa", new DateTime(2015, 09, 06));

            FruitBasket basket1 = new FruitBasket(Apple, "LARGE", 20, 10, 20, 20, "Apples are good for you!");
            FruitBasket basket2 = new FruitBasket(Mango, "SMALL", 50, 10, 20, 20, "Mangos'R'Us");

            List<Variance> variances = basket1.DetailedCompare(basket2);
            /* This should be 5 but there is a recursion/stack overflow issue if I try and adapt the
             * current solution to go into objects that have public properties and try to do a variance check
             * */
            Assert.IsTrue(variances.Count == 4);
        }