Пример #1
0
 public static IShippingCourier CreateShippingCourierFor(Order order)
 {
     if ((order.TotalCost > 100) || (order.WeightInKG > 5))
         return new DHL();
     else
         return new RoyalMail();
 }
        public void UKShippingCourierFactory_Should_Create_RoyalMail_Shipping_Courier_For_An_Order_With_A_Weight_In_KG_5_And_Under()
        {
            Order order = new Order() { WeightInKG = 5 };

            IShippingCourier courier = UKShippingCourierFactory.CreateShippingCourierFor(order);

            Assert.IsInstanceOfType(courier, typeof(RoyalMail));
        }
        public void UKShippingCourierFactory_Should_Create_DHL_Shipping_Courier_For_An_Order_With_A_Weight_In_KG_Over_5()
        {
            Order order = new Order() { WeightInKG = 6 };

            IShippingCourier courier = UKShippingCourierFactory.CreateShippingCourierFor(order);

            Assert.IsInstanceOfType(courier, typeof(DHL));
        }
        public void UKShippingCourierFactory_Should_Create_DHL_Shipping_Courier_For_An_Order_With_A_TotalCost_Of_Over_100()
        {
            Order order = new Order() { TotalCost = 101 };

            IShippingCourier courier = UKShippingCourierFactory.CreateShippingCourierFor(order);

            Assert.IsInstanceOfType(courier, typeof(DHL));
        }