コード例 #1
0
ファイル: GroundShipper.cs プロジェクト: owaisfas/talks
 public ShippingResult ShipOrder(Customer customer, Order order, Destination destination)
 {
     //can only ship via ground to the customer's own address
     if (new GroundShippingApprovalRule(destination).IsSatisfiedBy(customer))
         //do something here with customer, order, and destination
         return ShippingResult.Success;
     else
         return ShippingResult.Failure;
 }
コード例 #2
0
ファイル: AirFreightShipper.cs プロジェクト: owaisfas/talks
 public ShippingResult ShipOrder(Customer customer, Order order, Destination destination)
 {
     //can only ship via air if not in a too-nearby state
     if (new AirShippingApprovalRule(destination).IsSatisfiedBy(customer))
         //do something here with customer, order, and destination
         return ShippingResult.Success;
     else
         return ShippingResult.Failure;
 }
コード例 #3
0
            public void ShipOrder_Can_Return_Success()
            {
                Customer customer = new Customer();

                Order order = new Order();
                Destination destination = new Destination("123", "Main Street", "Anywhere", new State("SomeState", "SS"), "12345");

                customer.ChangeAddress(destination);

                IShipOrders groundShipper = new GroundShipper();

                Assert.That(groundShipper.ShipOrder(customer, order, destination), Is.EqualTo(ShippingResult.Success));
            }