Esempio n. 1
0
        public void ValidOrder_ReturnsOrderSummary()
        {
            var order = MakeOrders();

            _mockIProductRepository.Stub(a => a.IsInStock("ABCDE")).Return(true);
            _mockIProductRepository.Stub(a => a.IsInStock("BCDEF")).Return(true);

            _mockIOrderFulfillmentService.Stub(s => s.Fulfill(order))
            .Return(new OrderConfirmation {
                OrderNumber = "AX1123", CustomerId = 1, OrderId = 7
            });

            var orderService = new OrderService(_mockIProductRepository, _mockICustomerRepository, _mockIEmailService,
                                                _mockIOrderFulfillmentService, _mockITaxRateService);

            var customer = new Customer
            {
                CustomerId      = 1,
                PostalCode      = "99999",
                StateOrProvince = "WA"
            };

            _mockICustomerRepository.Stub(c => c.Get(Arg <int> .Is.Anything)).Return(customer);

            var orderSummary = orderService.PlaceOrder(order);

            Assert.IsNotNull(orderSummary);
            _mockIOrderFulfillmentService.AssertWasCalled(ofs => ofs.Fulfill(order));
        }
        public void PlaceOrder_OrderValid_SubmitsOrderToOrderFulfillmentService()
        {
            // Arrange
            StubProductRepository(true, SkuConstString);
            StubFulfillOrder(new OrderConfirmation());

            StubGetStandardCustomerFromRepository();
            StubTaxRateService(null);

            // Act
            _orderService.PlaceOrder(_order);


            // Assert
            _mockOrderFulfillmentService.AssertWasCalled(o => o.Fulfill(_order));
        }
Esempio n. 3
0
 public void Test_OrderFullFilment_Service_Was_Called_Once()
 {
     _order = CreateOrderObject(product_sku_1, product_sku_2);
     _orderService.PlaceOrder(_order);
     _orderFulfillmentService.AssertWasCalled(s => s.Fulfill(_order), options => options.Repeat.Times(1));
 }