public async Task AddOrderAsyncShouldThrownIfOrderDoesntExist()
        {
            const string customerId = nameof(customerId);

            var shoppingCartRepository = new Mock <IRepository <ShoppingCart> >();
            var orderRepository        = new Mock <IRepository <Order> >();
            var productService         = Mock.Of <IProductService>();

            shoppingCartRepository.Setup(scr => scr.All())
            .Returns(new ShoppingCart[]
            {
                new ShoppingCart
                {
                    CustomerId = customerId,
                },
            }
                     .AsQueryable);
            orderRepository.Setup(or => or.All())
            .Returns(new Order[0].AsQueryable);

            IShoppingCartService service = new ShoppingCartService(
                shoppingCartRepository.Object,
                orderRepository.Object,
                productService);

            await Assert.ThrowsAsync <ServiceException>(async() =>
            {
                await service.AddOrderAsync(customerId, nameof(Order.Id));
            });
        }
        public async Task AddOrderAsyncShouldWorkCorrectly()
        {
            const string customerId = nameof(customerId);
            const string orderId    = nameof(orderId);

            ApplicationDbContext dbContext = this.GetNewDbContext();

            ShoppingCart shoppingCart = new ShoppingCart
            {
                CustomerId = customerId,
            };

            dbContext.ShoppingCarts.Add(shoppingCart);

            await dbContext.SaveChangesAsync();

            var shoppingCartRepository = new EfRepository <ShoppingCart>(dbContext);
            var orderRepository        = new Mock <IRepository <Order> >();
            var productService         = Mock.Of <IProductService>();

            orderRepository.Setup(or => or.All())
            .Returns(new Order[]
            {
                new Order
                {
                    Id = orderId,
                },
            }
                     .AsQueryable);

            IShoppingCartService service = new ShoppingCartService(
                shoppingCartRepository,
                orderRepository.Object,
                productService);

            await service.AddOrderAsync(customerId, orderId);

            Assert.Single(shoppingCart.Orders);
            Assert.Equal(orderId, shoppingCart.Orders.First().Id);
        }