public void SetUp()
        {
            _pies = BuildPies();
            _mockPieRepository = new MockPieRepository().MockGetAllPies(_pies);

            _context = MockAppDbContext.BuildContextInMemoryDb();
            BuildCartWithItems(_context);
            _shoppingCart = new ShoppingCart(_context);
            _shoppingCart.ShoppingCartId = "1";

            _sut = new ShoppingCartController(_mockPieRepository.Object, _shoppingCart);
        }
        public void Checkout_WhenShoppingCartContainsItems_ReturnsARedirectToAction()
        {
            // Arrange
            AppDbContext context = MockAppDbContext.BuildContextInMemoryDb();

            BuildCartWithItems(context);

            Order order = new Order();
            var   mockOrderRepository = new MockOrderRepository()
                                        .CreateOrder(order);

            var sut = new OrderController(mockOrderRepository.Object,
                                          new ShoppingCart(context));

            // Act
            var result = sut.Checkout(order);

            // Assert
            Assert.IsAssignableFrom <RedirectToActionResult>(result);
            mockOrderRepository.Verify(x => x.CreateOrder(order), Times.Once());
        }
        public void Checkout_WhenShoppingCartIsEmpty_ReturnsAViewResult()
        {
            // Arrange
            AppDbContext context = MockAppDbContext.BuildContextInMemoryDb();

            BuildEmptyCart(context);

            Order order = new Order();
            var   mockOrderRepository = new MockOrderRepository()
                                        .CreateOrder(order);

            var sut = new OrderController(mockOrderRepository.Object,
                                          new ShoppingCart(context));

            // Act
            var result = sut.Checkout(order);

            // Assert
            Assert.IsAssignableFrom <ViewResult>(result);
            mockOrderRepository.Verify(x => x.CreateOrder(order), Times.Never());
        }