Exemplo n.º 1
0
        public async Task UpdateAsync()
        {
            var dataAccess = new StockDataAccess(this.Context, Mapper());

            //Act
            var sutCreate    = new CreateStockCommandHandler(dataAccess);
            var resultCreate = await sutCreate.Handle(new CreateStockCommand
            {
                Data = StockTestData.StockDTO
            }, CancellationToken.None);

            //Act
            var sutUpdate    = new UpdateStockCommandHandler(dataAccess);
            var resultUpdate = await sutUpdate.Handle(new UpdateStockCommand
            {
                Data = new StockDTO
                {
                    Id       = resultCreate.Data.Id,
                    Quantity = 50
                }
            }, CancellationToken.None);

            //Assert
            Assert.IsTrue(resultUpdate.Succeeded);
        }
        public void Should_ThrowException_When_MerchantProductDoesNotExist(string no1)
        {
            var handler = new UpdateStockCommandHandler(topSoldProductServiceMock.Object, dataSourceMock.Object);

            async Task action() => await handler.Handle(new UpdateStockCommand(no1), CancellationToken.None);

            Assert.ThrowsAsync <UpdatedMerchantProductNoDoesNotExistException>(action);
        }
        public async Task Should_UpdateStockProduct_When_MerchantProductExist(string no1, string no2)
        {
            topSoldProductServiceMock.GetOrderTopSoldProducts(LineFactory.CreateLines(
                                                                  LineFactory.CreateLine(no1),
                                                                  LineFactory.CreateLine(no2)
                                                                  ));
            var handler = new UpdateStockCommandHandler(topSoldProductServiceMock.Object, dataSourceMock.Object);

            await handler.Handle(new UpdateStockCommand(no2), CancellationToken.None);
        }