This post is based on Mosh Hamedani’s course at Udemy.com. It’s from his C# Intermediate course, section 6 on Interfaces, in the video called Interfaces and Testability. It is lengthy video with a fair amount of code to follow.
In this example we are going to see a hypothetical OrderProcessor. This object will take in an Order. Next we need to call the Process() method of the Order Processor and pass the Order to the method Processs(). We can see all of this in the Main() below. To process an order we need to calculate the shipping cost. We also need to save the date that the order was shipped. We have a business rule that says we always ship the next day. To calculate the shipping cost we use our object ShippingCalculator.