static void Main(string[] args)
 {
     var orderProcessor = new OrderProcessor(new ShippingCalculator());
     var order          = new Order {
         DatePlaced = DateTime.Now, TotalPrice = 100f
     };
 }
Example #2
0
        static void Main(string[] args)
        {
            var orderProcessor = new OrderProcessor(new ShippingCalculator());      // Okay here.  Main class knows about concrete classes and ties them together
            var order          = new Order {
                DatePlaced = DateTime.Now, TotalPrice = 100f
            };

            orderProcessor.Process(order);
        }
Example #3
0
        static void Main(string[] args)
        {
            var orderProcessor = new OrderProcessor();
            var order          = new Order {
                DatePlaced = DateTime.Now, TotalPrice = 100f
            };

            orderProcessor.Process(order);
        }
Example #4
0
        public static void Main(string[] args)
        {
            var orderProcessor = new OrderProcessor(new ShippingCalculator());
            var order          = new Order {
                DatePlaced = DateTime.Now, TotalPrice = 100f
            };

            orderProcessor.Process(order);
            Console.WriteLine("Hello World!");
        }
Example #5
0
        static void Main(string[] args)
        {
            // orderProcessor needs instance of IShippingCalculator
            var orderProcessor = new OrderProcessor(new ShippingCalculator());
            var order          = new Order {
                DatePlaced = DateTime.Now, TotalPrice = 100f
            };

            orderProcessor.Process(order);
            Console.ReadLine();
        }
Example #6
0
        static void Main(string[] args)
        {
            var orderProcessor = new OrderProcessor(new ShippingCalculator());
            var order          = new Order {
                DatePlaced = DateTime.Now, TotalPrice = 100f
            };

            orderProcessor.Process(order);

            Console.ReadKey();
        }
Example #7
0
        static void Main(string[] args)
        {
            //orderProcessor concrete class doesnt know about the existence of other concrete classes..so dependency is safe
            var orderProcessor = new OrderProcessor(new ShippingCalculator());
            var order          = new Order
            {
                DatePlaced = DateTime.Now,
                TotalPrice = 100f
            };

            orderProcessor.Process(order);
        }
Example #8
0
        public void Process(OrderProcessor order)
        {
            if (order.IsShipped)
            {
                throw new InvalidOperationException("This order is already processed.");
            }

            order.Shipment = new Shipment
            {
                Cost         = _shippingCalculator.CalculateShipping(order),
                ShippingDate = DateTime.Today.AddDays(1)
            };
        }
Example #9
0
        static void Main(string[] args)
        {
            var orderProcessor = new OrderProcessor(new ShippingCalculator());
            var order          = new Order {
                DatePlaced = DateTime.Now, TotalPrice = 100f
            };

            orderProcessor.Process(order);

            Console.WriteLine("=========================================================================");
            Console.WriteLine("In order to unit test a class, we need to isolate it.\n");
            Console.WriteLine("So in order to test the OrderProcessor class,");
            Console.WriteLine("it has to be isolated from the concrete ShippingCalculator class.\n");
            Console.WriteLine("It can be loosely coupled with the IShippingCalculator interface instead.");
            Console.WriteLine("=========================================================================");
        }
 static void Main(string[] args)
 {
     var orderProcessor = new OrderProcessor(new ShippingCalculator());
     var order = new Order {DatePlaced = DateTime.Now, TotalPrice = 100f};
     orderProcessor.Process(order);
 }
Example #11
0
 static void Main(string[] args)
 {
     var orderProcessor = new OrderProcessor(new ShippingCalculator());
 }