public void UpdateInventoryEntryByIdChangeQuantity() { IClient commerceToolsClient = this.inventoryFixture.GetService <IClient>(); InventoryEntry inventoryEntry = this.inventoryFixture.CreateInventoryEntry(); long newQuantity = TestingUtility.RandomInt(100, 1000); List <UpdateAction <InventoryEntry> > updateActions = new List <UpdateAction <InventoryEntry> >(); ChangeQuantityUpdateAction changeQuantityUpdateAction = new ChangeQuantityUpdateAction() { Quantity = newQuantity }; updateActions.Add(changeQuantityUpdateAction); //Sets quantityOnStock and updates availableQuantity according to the new quantity InventoryEntry retrievedInventoryEntry = commerceToolsClient .ExecuteAsync(new UpdateByIdCommand <InventoryEntry>(new Guid(inventoryEntry.Id), inventoryEntry.Version, updateActions)).Result; this.inventoryFixture.InventoryEntries.Add(retrievedInventoryEntry); Assert.Equal(retrievedInventoryEntry.Id, inventoryEntry.Id); Assert.Equal(newQuantity, retrievedInventoryEntry.QuantityOnStock); Assert.Equal(newQuantity, retrievedInventoryEntry.AvailableQuantity); }
public async void UpdateInventoryEntryChangeQuantity() { await WithUpdateableInventoryEntry(client, DefaultInventoryEntryDraft, async inventoryEntry => { var newQuantity = TestingUtility.RandomInt(100, 1000); var action = new ChangeQuantityUpdateAction { Quantity = newQuantity }; var updatedInventoryEntry = await client .ExecuteAsync(inventoryEntry.UpdateById(actions => actions.AddUpdate(action))); Assert.Equal(newQuantity, updatedInventoryEntry.QuantityOnStock); Assert.Equal(newQuantity, updatedInventoryEntry.AvailableQuantity); return(updatedInventoryEntry); }); }