public void ThrowArgumentOutOfRangeException_InventoryProductsIsEmpty()
        {
            var command = new BuyProductsCommand(new List <InventoryProduct>());
            var handler = new BuyProductsCommandHandler(this._unitOfwork.Object);

            Assert.ThrowsAnyAsync <ArgumentOutOfRangeException>(() => handler.Handle(command, new CancellationToken()));
        }
        public void ThrowArgumentNullException_InventoryProductsIsNull()
        {
            var command = new BuyProductsCommand(null);
            var handler = new BuyProductsCommandHandler(this._unitOfwork.Object);

            Assert.ThrowsAnyAsync <ArgumentNullException>(() => handler.Handle(command, new CancellationToken()));
        }
        public async void ReturnTrue_AllInventoryProductsUpdated()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "ReturnTrue_AllInventoryProductsUpdated")
                          .Options;

            using (var context = new ApplicationDbContext(options))
            {
                var unitOfWork = new UnitOfWork <ApplicationDbContext>(context);

                unitOfWork.Repository.Add(new InventoryProduct()
                {
                    Amount = 5, Id = 1, ProductId = 1, Price = 10.0
                });
                unitOfWork.Repository.Add(new InventoryProduct()
                {
                    Amount = 5, Id = 2, ProductId = 2, Price = 10.0
                });

                await unitOfWork.SaveChanges();
            }

            using (var context = new ApplicationDbContext(options))
            {
                var unitOfWork = new UnitOfWork <ApplicationDbContext>(context);

                var inventoryProducts = new List <InventoryProduct>()
                {
                    new InventoryProduct()
                    {
                        Amount = 4, Id = 1, ProductId = 1, Price = 10.0
                    },
                    new InventoryProduct()
                    {
                        Amount = 4, Id = 2, ProductId = 2, Price = 10.0
                    }
                };

                var command = new BuyProductsCommand(inventoryProducts);

                var handler = new BuyProductsCommandHandler(unitOfWork);

                Assert.True(handler.Handle(command, new CancellationToken()).Result);
            }
        }