Ejemplo n.º 1
0
        public void it_does_not_shallow_copies_reference_items()
        {
            _testOutputHelper.WriteLine("Original order: ");
            FoodOrder savedOrder = new FoodOrder("Harrison",
                                                 true,
                                                 new[] { "Pizza", "Coke" },
                                                 _testOutputHelper,
                                                 new OrderInfo(2345));

            savedOrder.Debug();

            _testOutputHelper.WriteLine("Cloned Order");
            FoodOrder clonedOrder = (FoodOrder)savedOrder.ShallowCopy();

            clonedOrder.Debug();

            // change one non reference item and one reference item and it will change the reference item which it should not
            // i.e The id in the cloned order is changed to 5555 when it shouldn't
            // It should be same behaviour as name and not change the name for cloned order variable
            _testOutputHelper.WriteLine("Order changes :");
            savedOrder.customerName = "Jeff";
            savedOrder.info.id      = 5555;
            savedOrder.Debug();
            clonedOrder.Debug();
        }
Ejemplo n.º 2
0
        public void it_does_deep_copies_of_all_properties()
        {
            _testOutputHelper.WriteLine("Original order: ");
            FoodOrder savedOrder = new FoodOrder("Harrison",
                                                 true,
                                                 new[] { "Pizza", "Coke" },
                                                 _testOutputHelper,
                                                 new OrderInfo(2345));

            savedOrder.Debug();

            _testOutputHelper.WriteLine("Cloned Order");
            FoodOrder clonedOrder = (FoodOrder)savedOrder.DeepCopy();

            clonedOrder.Debug();

            _testOutputHelper.WriteLine("Order changes :");
            savedOrder.customerName = "Jeff";
            savedOrder.info.id      = 5555;
            savedOrder.Debug();
            clonedOrder.Debug();
        }
Ejemplo n.º 3
0
        public void it_prints_food_order()
        {
            // Arrange
            FoodOrder savedOrder = new FoodOrder("Harrison",
                                                 true,
                                                 new[] { "Pizza", "Coke" },
                                                 _testOutputHelper,
                                                 new OrderInfo(2345));

            // Act - Assert
            _testOutputHelper.WriteLine("Original order: ");
            savedOrder.Debug();
        }
Ejemplo n.º 4
0
        public void it_shallow_copies_non_reference_items()
        {
            _testOutputHelper.WriteLine("Original order: ");

            FoodOrder savedOrder = new FoodOrder("Harrison",
                                                 true,
                                                 new[] { "Pizza", "Coke" },
                                                 _testOutputHelper,
                                                 new OrderInfo(2345));

            savedOrder.Debug();

            _testOutputHelper.WriteLine("Cloned Order");
            FoodOrder clonedOrder = (FoodOrder)savedOrder.ShallowCopy();

            clonedOrder.Debug();
        }