public void GetOrdersByUserReturnsEmptyListWithNoOrders()
        {
            Mock <IOrderRepository> orderRepository = new Mock <IOrderRepository>(MockBehavior.Strict);

            var orderService = new ca_service.Services.OrderService(orderRepository.Object, null, null, null);

            int userId = 12;

            orderRepository.Setup(x => x.GetOrdersForUser(userId)).Returns(() => new List <Order>());

            var result = orderService.GetOrdersForUser(userId);

            Assert.Equal(0, result.Count);

            orderRepository.VerifyAll();
        }
        public void GetOrdersByUserReturnOrders()
        {
            Mock <IOrderRepository> orderRepository = new Mock <IOrderRepository>(MockBehavior.Strict);

            Mock <IOrderItemRepository> orderItemRepository = new Mock <IOrderItemRepository>(MockBehavior.Strict);

            var orderService = new ca_service.Services.OrderService(orderRepository.Object, orderItemRepository.Object, null, null);

            int orderId = 42, orderItemId = 84, userId = 12;

            var order = new Order(orderId)
            {
                UserId = userId
            };

            var orderItem = new OrderItem(orderItemId)
            {
                OrderId = orderId
            };

            var orderItems = new List <OrderItem>()
            {
                orderItem
            };

            var orders = new List <Order>()
            {
                order
            };

            orderRepository.Setup(x => x.GetOrdersForUser(userId)).Returns(() => orders);

            orderItemRepository.Setup(x => x.GetByOrderId(orderId)).Returns(() => orderItems);

            var result = orderService.GetOrdersForUser(userId);

            Assert.NotNull(result);

            Assert.Equal(orders.Count, result.Count);

            Assert.Equal(orderId, result.First().Id);

            Assert.Equal(orderItemId, result.First().Items.First().Id);

            orderRepository.VerifyAll();
            orderItemRepository.VerifyAll();
        }