Example #1
0
        public void OrderItemsAreUniqueByProductSku()
        {
            var order = MakeOrders();

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

            _mockIProductRepository.Stub(a => a.IsInStock(Arg <string> .Is.Anything)).Return(true);

            var orderConfirmation = new OrderConfirmation {
                OrderNumber = "AX1123", CustomerId = 1, OrderId = 7
            };

            _mockIOrderFulfillmentService.Stub(s => s.Fulfill(order))
            .Return(orderConfirmation);

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

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

            var result = orderService.PlaceOrder(order);

            Assert.IsNotNull(result);
        }
Example #2
0
        public OrderServiceTests()
        {
            _customerRepository      = MockRepository.GenerateMock <ICustomerRepository>();
            _emailService            = MockRepository.GenerateMock <IEmailService>();
            _orderFulfillmentService = MockRepository.GenerateMock <IOrderFulfillmentService>();
            _productRepository       = MockRepository.GenerateMock <IProductRepository>();
            _taxRateService          = MockRepository.GenerateMock <ITaxRateService>();

            _taxEntries = new List <TaxEntry>()
            {
                CreateTaxEntry("test", 12),
                CreateTaxEntry("test2", 10)
            };

            _productRepository
            .Stub(p => p.IsInStock("product_1"))
            .Return(true);

            _productRepository
            .Stub(p => p.IsInStock("product_2"))
            .Return(true);

            var order = new Order();

            _orderFulfillmentService
            .Stub(o => o.Fulfill(order))
            .Return(new OrderConfirmation()
            {
                OrderNumber = "1001"
            });

            _taxRateService
            .Stub(t => t.GetTaxEntries(postalCode, country))
            .Return(_taxEntries);

            _orderService = new OrderService(_emailService, _orderFulfillmentService, _productRepository, _taxRateService, postalCode, country);
        }
 private void StubFulfillOrder(OrderConfirmation orderConfirmation)
 {
     _mockOrderFulfillmentService.Stub(o => o.Fulfill(_order)).Return(orderConfirmation);
 }