Ejemplo n.º 1
0
        public void Should_have_throw_exception_when_order_exist(int customerId, int orderId)
        {
            var order = new Order {
                OrderId = orderId, Amount = 100d
            };

            var orderService = new OrderService(MockCustomerOrderData.GetCustomerService_GetById_Return_Customer(customerId),
                                                calculationService, MockCustomerOrderData.GetOrderRepository_OrderExists(true));


            Assert.Throws <ArgumentException>(
                () => orderService.PlaceOrder(order, customerId));
        }
Ejemplo n.º 2
0
        public void Should_PlaceOrder(int customerId, int orderId, bool expected)
        {
            var order = new Order {
                OrderId = orderId, Amount = 100d
            };

            var orderService = new OrderService(MockCustomerOrderData.GetCustomerService_GetById_Return_Customer(customerId),
                                                calculationService, MockCustomerOrderData.GetOrderRepository_OrderExists(false));

            var isOrderPlaced = orderService.PlaceOrder(order, customerId);

            Assert.AreEqual(expected, isOrderPlaced);
        }
Ejemplo n.º 3
0
        public void Should_have_throw_exception_when_customer_does_not_exist(int customerId)
        {
            var order = new Order {
                OrderId = 1, Amount = 100d
            };

            var mockOrderRepository = new Mock <IOrderRepository>();

            var orderService = new OrderService(MockCustomerOrderData.GetCustomerService_GetById_Return_Null(customerId),
                                                calculationService, mockOrderRepository.Object);


            Assert.Throws <ArgumentException>(
                () => orderService.PlaceOrder(order, customerId));
        }