예제 #1
0
 public static OrderTestBuilder AnOrder()
 {
     return(new OrderTestBuilder(Order.OrderBuilder.Order()
                                 .WithCustomerId(Guid.NewGuid())
                                 .WithOrderItems(new List <OrderItem> {
         OrderItemTestBuilder.AnOrderItem().Build(), OrderItemTestBuilder.AnOrderItem().Build()
     })));
 }
예제 #2
0
        public void GetTotalPrice_givenOrderWithOrderItems_thenTotalPriceIsSumOfPricesOfOrderItemsMultipliedByOrderedAmount()
        {
            Order order = OrderTestBuilder.AnOrder()
                          .WithOrderItems(OrderItemTestBuilder.AnOrderItem().WithOrderedAmount(2).WithItemPrice(Price.Create(new decimal(40.50))).Build(),
                                          OrderItemTestBuilder.AnOrderItem().WithOrderedAmount(1).WithItemPrice(Price.Create(new decimal(60.50))).Build(),
                                          OrderItemTestBuilder.AnOrderItem().WithOrderedAmount(10).WithItemPrice(Price.Create(new decimal(25))).Build())
                          .Build();

            Price totalPrice = order.GetTotalPrice();

            Assert.Equal(391.5, totalPrice.GetAmountAsFloat());
        }