static void Main(string[] args) { var orderProcessor = new OrderProcessor(new ShippingCalculator()); var order = new Order { DatePlaced = DateTime.Now, TotalPrice = 100f }; }
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); }
static void Main(string[] args) { var orderProcessor = new OrderProcessor(); var order = new Order { DatePlaced = DateTime.Now, TotalPrice = 100f }; orderProcessor.Process(order); }
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!"); }
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(); }
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(); }
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); }
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) }; }
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); }
static void Main(string[] args) { var orderProcessor = new OrderProcessor(new ShippingCalculator()); }