public async Task WhenCreate_ThenSuccess() { var headers = await _defaultRequestHeadersService.GetAsync(); var room = await _create.StockRoom.BuildAsync(); var productStatus = await _create.ProductStatus.BuildAsync(); var product = await _create.Product .WithStatusId(productStatus.Id) .BuildAsync(); var balance = new StockBalance { Id = Guid.NewGuid(), RoomId = room.Id, ProductId = product.Id, Count = 1, IsDeleted = true }; var createdBalanceId = await _stockBalancesClient.CreateAsync(balance, headers); var createdBalance = await _stockBalancesClient.GetAsync(createdBalanceId, headers); Assert.NotNull(createdBalance); Assert.Equal(createdBalanceId, createdBalance.Id); Assert.Equal(balance.RoomId, createdBalance.RoomId); Assert.Equal(balance.ProductId, createdBalance.ProductId); Assert.Equal(balance.Count, createdBalance.Count); Assert.True(!createdBalance.CreateUserId.IsEmpty()); Assert.Equal(balance.IsDeleted, createdBalance.IsDeleted); Assert.True(createdBalance.CreateDateTime.IsMoreThanMinValue()); }
public async Task <StockBalance> BuildAsync() { var headers = await _defaultRequestHeadersService.GetAsync(); if (_balance.RoomId.IsEmpty()) { throw new InvalidOperationException(nameof(_balance.RoomId)); } if (_balance.ProductId.IsEmpty()) { throw new InvalidOperationException(nameof(_balance.ProductId)); } var id = await _balancesClient.CreateAsync(_balance, headers); return(await _balancesClient.GetAsync(id, headers)); }