public async void ItShouldRemoveAnOrderItem()
        {
            //Given
            EFCoreOrderRepository orderRepo = new EFCoreOrderRepository(ctx);
            EFCoreUserRepository  userRepo  = new EFCoreUserRepository(ctx);
            await userRepo.Add(mockUser);

            VendorAppUser newUser = (await userRepo.GetAll()).ElementAt(0);

            //When
            mockOrder.User = newUser;
            await orderRepo.Add(mockOrder);

            Order tempOrder = (await orderRepo.GetAll()).ElementAt(0);

            tempOrder.OrderItems = new List <OrderItem> {
                mockOrderItem
            };
            await orderRepo.Update(tempOrder);

            OrderItem tempOrderItem = (await orderRepo.GetAllOrderItems()).ElementAt(0);
            await orderRepo.RemoveOrderItem(tempOrderItem.ID);

            //Then
            Assert.Equal(0, (await orderRepo.GetAllOrderItems()).Count());
        }
        public async void ItShouldUpdateAnOrderItem()
        {
            //Given
            EFCoreOrderRepository orderRepo = new EFCoreOrderRepository(ctx);
            EFCoreUserRepository  userRepo  = new EFCoreUserRepository(ctx);
            await userRepo.Add(mockUser);

            VendorAppUser newUser = (await userRepo.GetAll()).ElementAt(0);

            //When
            mockOrder.User = newUser;
            await orderRepo.Add(mockOrder);

            Order tempOrder = (await orderRepo.GetAll()).ElementAt(0);

            tempOrder.OrderItems = new List <OrderItem> {
                mockOrderItem
            };
            await orderRepo.Update(tempOrder);

            OrderItem tempOrderItem = (await orderRepo.GetAllOrderItems()).ElementAt(0);

            tempOrderItem.ProductName = "New Product Name";
            await orderRepo.UpdateOrderItem(tempOrderItem);

            //Then
            OrderItem actualOrderItem = (await orderRepo.GetAllOrderItems()).ElementAt(0);

            Assert.Equal("New Product Name", actualOrderItem.ProductName);
        }
        public async void ItShouldUpdateAOrder()
        {
            //Given
            EFCoreOrderRepository orderRepo = new EFCoreOrderRepository(ctx);
            EFCoreUserRepository  userRepo  = new EFCoreUserRepository(ctx);
            await userRepo.Add(mockUser);

            VendorAppUser newUser = (await userRepo.GetAll()).ElementAt(0);

            //When
            mockOrder.User = newUser;
            await orderRepo.Add(mockOrder);

            Order tempOrder = (await orderRepo.GetAll()).ElementAt(0);

            tempOrder.OrderItems = new List <OrderItem> {
                mockOrderItem
            };
            await orderRepo.Update(tempOrder);

            //Then
            Order actualOrder = (await orderRepo.GetAll()).ElementAt(0);

            Assert.Equal(1, actualOrder.OrderItems.Count());
        }
        public async void ItShouldCreateAOrder()
        {
            //Given
            EFCoreOrderRepository orderRepo = new EFCoreOrderRepository(ctx);
            EFCoreUserRepository  userRepo  = new EFCoreUserRepository(ctx);
            await userRepo.Add(mockUser);

            VendorAppUser newUser = (await userRepo.GetAll()).ElementAt(0);

            //When
            mockOrder.User = newUser;
            await orderRepo.Add(mockOrder);

            //Then
            Order actualOrder = (await orderRepo.GetAll()).ElementAt(0);

            Assert.Equal(1, actualOrder.ID);
        }
        public async void ItShouldRemoveAOrder()
        {
            //Given
            EFCoreOrderRepository orderRepo = new EFCoreOrderRepository(ctx);
            EFCoreUserRepository  userRepo  = new EFCoreUserRepository(ctx);
            await userRepo.Add(mockUser);

            VendorAppUser newUser = (await userRepo.GetAll()).ElementAt(0);

            //When
            mockOrder.User = newUser;
            await orderRepo.Add(mockOrder);

            Order tempOrder = (await orderRepo.GetAll()).ElementAt(0);
            await orderRepo.Delete(tempOrder.ID);

            //Then
            Assert.Equal(0, (await orderRepo.GetAll()).Count());
        }
 public OrderController(IRepository <Order> repository, UserManager <VendorAppUser> userManager)
 {
     orderRepo        = repository as EFCoreOrderRepository;
     this.userManager = userManager;
 }