Esempio n. 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);
            }
        }
Esempio n. 2
0
        public void CompareNullMangoToApple()
        {
            Fruit Apple = new Fruit("Sweet", "Ripe", "England", new DateTime(2014, 08, 06));
            Fruit Mango = null;

            List<Variance> variances = Mango.DetailedCompare(Apple);
            Assert.IsTrue(variances == null);
        }
Esempio n. 3
0
        public void CompareFruit()
        {
            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);
            Assert.IsTrue(variances.Count > 0);
        }
Esempio n. 4
0
 public FruitBasket(Fruit fruit, string size, int weight, int height, 
     int depth, int width, string name)
 {
     this.fruit = fruit;
     this.Size = size;
     this.Weight = weight;
     this.Height = height;
     this.Depth = depth;
     this.Width = width;
     this.Name = name;
 }
Esempio n. 5
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);
        }