예제 #1
0
        public void should_decrease_correct_when_add_order()
        {
            // setup
            var stubOrderRepository = new StubOrderRepository();
            var stubCustomerService = new StubCustomerService();
            var stubProductService  = new StubProductService();
            var mockStockService    = new MockStockService(hasPickCalled: false);

            // exercise
            var sut = new OrderService(stubOrderRepository, stubProductService, stubCustomerService, mockStockService);

            sut.AddOrder(1, 2, 3);

            // verify
            Assert.True(mockStockService.HasPickCalled);

            // teardown
        }
예제 #2
0
        public void should_add_an_order()
        {
            // setup
            var fakeOrderRepository = new FakeOrderRepository();
            var stubCustomerService = new StubCustomerService();
            var stubProductService  = new StubProductService();
            var mockStockService    = new StubStockService();

            // exercise
            var sut = new OrderService(fakeOrderRepository, stubProductService, stubCustomerService, mockStockService);

            sut.AddOrder(1, 2, 3);

            // verify
            var order = fakeOrderRepository.GetById(1);

            Assert.Equal(1, order.Id);
            Assert.Equal(1, order.Product.Id);
            Assert.Equal(2, order.Customer.Id);
            Assert.Equal(3, order.Count);

            // teardown
        }