public void UpdateInventoryEntryByIdSetCustomType() { IClient commerceToolsClient = this.inventoryFixture.GetService <IClient>(); InventoryEntry inventoryEntry = this.inventoryFixture.CreateInventoryEntry(); var type = this.inventoryFixture.CreateNewType(); var fields = this.inventoryFixture.CreateNewFields(); List <UpdateAction <InventoryEntry> > updateActions = new List <UpdateAction <InventoryEntry> >(); SetCustomTypeUpdateAction setCustomTypeUpdateAction = new SetCustomTypeUpdateAction() { Type = new ResourceIdentifier <Type> { Key = type.Key }, Fields = fields }; updateActions.Add(setCustomTypeUpdateAction); 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(type.Id, retrievedInventoryEntry.Custom.Type.Id); }
public async void UpdateInventoryEntrySetCustomType() { var fields = CreateNewFields(); await WithType(client, async type => { await WithUpdateableInventoryEntry(client, DefaultInventoryEntryDraft, async inventoryEntry => { Assert.Null(inventoryEntry.Custom); var action = new SetCustomTypeUpdateAction { Type = type.ToKeyResourceIdentifier(), Fields = fields }; var updatedInventoryEntry = await client .ExecuteAsync(inventoryEntry.UpdateById(actions => actions.AddUpdate(action))); Assert.NotNull(updatedInventoryEntry.Custom); Assert.Equal(type.Id, updatedInventoryEntry.Custom.Type.Id); return(updatedInventoryEntry); }); }); }
public async Task UpdateDiscountCodeSetCustomType() { var fields = CreateNewFields(); await WithType(client, async type => { await WithUpdateableDiscountCode(client, async discountCode => { var updateActions = new List <UpdateAction <DiscountCode> >(); var setTypeAction = new SetCustomTypeUpdateAction { Type = type.ToKeyResourceIdentifier(), Fields = fields }; updateActions.Add(setTypeAction); var updatedCartDiscount = await client.ExecuteAsync(new UpdateByIdCommand <DiscountCode>(discountCode, updateActions)); Assert.Equal(type.Id, updatedCartDiscount.Custom.Type.Id); return(updatedCartDiscount); }); }); }
public void UpdatePaymentByIdSetCustomType() { IClient commerceToolsClient = this.paymentsFixture.GetService <IClient>(); Payment payment = this.paymentsFixture.CreatePayment(); var type = this.paymentsFixture.CreateNewType(); var fields = this.paymentsFixture.CreateNewFields(); var updateActions = new List <UpdateAction <Payment> >(); var setCustomTypeUpdateAction = new SetCustomTypeUpdateAction() { Type = new ResourceIdentifier <Type> { Key = type.Key }, Fields = fields }; updateActions.Add(setCustomTypeUpdateAction); var retrievedPayment = commerceToolsClient .ExecuteAsync(new UpdateByIdCommand <Payment>(payment.Id, payment.Version, updateActions)).Result; this.paymentsFixture.PaymentsToDelete.Add(retrievedPayment); Assert.Equal(retrievedPayment.Id, payment.Id); Assert.Equal(type.Id, retrievedPayment.Custom.Type.Id); }
public async Task UpdateShoppingListSetCustomType() { var fields = CreateNewFields(); await WithType(client, async type => { await WithUpdateableShoppingList(client, async shoppingList => { var updateActions = new List <UpdateAction <ShoppingList> >(); var setTypeAction = new SetCustomTypeUpdateAction { Type = type.ToKeyResourceIdentifier(), Fields = fields }; updateActions.Add(setTypeAction); var updatedShoppingList = await client.ExecuteAsync(new UpdateByIdCommand <ShoppingList>(shoppingList, updateActions)); Assert.Equal(type.Id, updatedShoppingList.Custom.Type.Id); return(updatedShoppingList); }); }); }
public void UpdateCustomerGroupByIdSetCustomType() { IClient commerceToolsClient = this.customerGroupFixture.GetService <IClient>(); CustomerGroup customerGroup = this.customerGroupFixture.CreateCustomerGroup(); var type = this.customerGroupFixture.CreateNewType(); var fields = this.customerGroupFixture.CreateNewFields(); List <UpdateAction <CustomerGroup> > updateActions = new List <UpdateAction <CustomerGroup> >(); SetCustomTypeUpdateAction setCustomTypeUpdateAction = new SetCustomTypeUpdateAction() { Type = new ResourceIdentifier <Type> { Id = type.Id }, Fields = fields }; updateActions.Add(setCustomTypeUpdateAction); CustomerGroup retrievedCustomerGroup = commerceToolsClient .ExecuteAsync(new UpdateByIdCommand <CustomerGroup>(new Guid(customerGroup.Id), customerGroup.Version, updateActions)).Result; this.customerGroupFixture.CustomerGroupsToDelete.Add(retrievedCustomerGroup); Assert.Equal(type.Id, retrievedCustomerGroup.Custom.Type.Id); }
public async Task UpdateCustomerGroupSetCustomType() { var fields = CreateNewFields(); await WithType(client, async type => { await WithUpdateableCustomerGroup(client, async customerGroup => { var action = new SetCustomTypeUpdateAction { Type = type.ToKeyResourceIdentifier(), Fields = fields }; var updatedCustomerGroup = await client .ExecuteAsync(customerGroup.UpdateByKey(actions => actions.AddUpdate(action))); Assert.Equal(type.Id, updatedCustomerGroup.Custom.Type.Id); return(updatedCustomerGroup); }); }); }
public async Task UpdateShippingMethodSetCustomType() { var fields = CreateNewFields(); await WithType(client, async type => { await WithUpdateableShippingMethod(client, async shippingMethod => { var action = new SetCustomTypeUpdateAction { Type = type.ToKeyResourceIdentifier(), Fields = fields }; var updatedShippingMethod = await client .ExecuteAsync(shippingMethod.UpdateByKey(actions => actions.AddUpdate(action))); Assert.Equal(type.Id, updatedShippingMethod.Custom.Type.Id); return(updatedShippingMethod); }); }); }
public async Task UpdateReviewSetCustomType() { var fields = CreateNewFields(); await WithType(client, async type => { await WithUpdateableReview(client, async review => { var updateActions = new List <UpdateAction <Review> >(); var setTypeAction = new SetCustomTypeUpdateAction { Type = type.ToKeyResourceIdentifier(), Fields = fields }; updateActions.Add(setTypeAction); var updatedReview = await client.ExecuteAsync(new UpdateByIdCommand <Review>(review, updateActions)); Assert.Equal(type.Id, updatedReview.Custom.Type.Id); return(updatedReview); }); }); }
public async Task UpdateChannelSetCustomType() { var fields = CreateNewFields(); await WithType(client, async type => { await WithUpdateableChannel(client, async channel => { var updateActions = new List <UpdateAction <Channel> >(); var setTypeAction = new SetCustomTypeUpdateAction { Type = type.ToKeyResourceIdentifier(), Fields = fields }; updateActions.Add(setTypeAction); var updatedChannel = await client.ExecuteAsync(new UpdateByIdCommand <Channel>(channel, updateActions)); Assert.Equal(type.Id, updatedChannel.Custom.Type.Id); return(updatedChannel); }); }); }