public async Task WhenGetPagedList_ThenSuccess() { var headers = await _defaultRequestHeadersService.GetAsync(); var productStatus = await _create.ProductStatus.BuildAsync(); var room = await _create.StockRoom .BuildAsync(); var product = await _create.Product .WithStatusId(productStatus.Id) .BuildAsync(); var consumption = await _create.StockConsumption .WithType(StockConsumptionType.SaleToCustomer) .WithOrderId(Guid.NewGuid()) .WithItem(room.Id, product.Id, 1) .BuildAsync(); consumption.IsDeleted = true; await _stockConsumptionsClient.UpdateAsync(consumption, headers); var request = new StockConsumptionChangeGetPagedListRequest { StockConsumptionId = consumption.Id, SortBy = "CreateDateTime", OrderBy = "asc" }; var response = await _stockConsumptionChangesClient.GetPagedListAsync(request, headers); Assert.NotEmpty(response.Changes); Assert.True(response.Changes.All(x => !x.ChangerUserId.IsEmpty())); Assert.True(response.Changes.All(x => x.StockConsumptionId == consumption.Id)); Assert.True(response.Changes.All(x => x.CreateDateTime.IsMoreThanMinValue())); Assert.True(response.Changes.First().OldValueJson.IsEmpty()); Assert.True(!response.Changes.First().NewValueJson.IsEmpty()); Assert.NotNull(response.Changes.First().NewValueJson.FromJsonString <StockConsumption>()); Assert.True(!response.Changes.Last().OldValueJson.IsEmpty()); Assert.True(!response.Changes.Last().NewValueJson.IsEmpty()); Assert.False(response.Changes.Last().OldValueJson.FromJsonString <StockConsumption>().IsDeleted); Assert.True(response.Changes.Last().NewValueJson.FromJsonString <StockConsumption>().IsDeleted); }
public async Task WhenUpdate_ThenSuccess() { var headers = await _defaultRequestHeadersService.GetAsync(); var productStatus = await _create.ProductStatus.BuildAsync(); var room = await _create.StockRoom .BuildAsync(); var product = await _create.Product .WithStatusId(productStatus.Id) .BuildAsync(); var consumption = await _create.StockConsumption .WithType(StockConsumptionType.ReturnToSupplier) .WithItem(room.Id, product.Id, 1) .BuildAsync(); var orderId = Guid.NewGuid(); consumption.Type = StockConsumptionType.SaleToCustomer; consumption.OrderId = orderId; consumption.IsDeleted = true; consumption.Items.First(x => x.ProductId == product.Id).Count = 2; await _stockConsumptionsClient.UpdateAsync(consumption, headers); var updatedConsumption = await _stockConsumptionsClient.GetAsync(consumption.Id, headers); Assert.Equal(consumption.AccountId, updatedConsumption.AccountId); Assert.Equal(consumption.Type, updatedConsumption.Type); Assert.Equal(consumption.CreateUserId, updatedConsumption.CreateUserId); Assert.Equal(consumption.OrderId, updatedConsumption.OrderId); Assert.Equal(consumption.IsDeleted, updatedConsumption.IsDeleted); Assert.Equal(consumption.Items.Single().ProductId, updatedConsumption.Items.Single().ProductId); Assert.Equal(consumption.Items.Single().Count, updatedConsumption.Items.Single().Count); }