public void UpdateTypeByIdAddFieldDefinition() { IClient commerceToolsClient = this.typeFixture.GetService <IClient>(); Type type = this.typeFixture.CreateType(); List <UpdateAction <Type> > updateActions = new List <UpdateAction <Type> >(); string newKey = TestingUtility.RandomString(10); AddFieldDefinitionUpdateAction addFieldDefinitionUpdateAction = new AddFieldDefinitionUpdateAction() { FieldDefinition = this.typeFixture.CreateNewStringFieldDefinition() }; updateActions.Add(addFieldDefinitionUpdateAction); Type retrievedType = commerceToolsClient.ExecuteAsync(new UpdateByIdCommand <Type>(new Guid(type.Id), type.Version, updateActions)).Result; this.typeFixture.TypesToDelete.Add(retrievedType); Assert.Equal(type.FieldDefinitions.Count + 1, retrievedType.FieldDefinitions.Count); }
public async Task UpdateTypeAddFieldDefinition() { var stringField = CreateStringFieldDefinition(); await WithUpdateableType(client, DefaultTypeDraftWithoutFields, async type => { Assert.Empty(type.FieldDefinitions); var updateActions = new List <UpdateAction <Type> >(); var addFieldDefinitionAction = new AddFieldDefinitionUpdateAction { FieldDefinition = stringField }; updateActions.Add(addFieldDefinitionAction); var updatedType = await client .ExecuteAsync(new UpdateByIdCommand <Type>(type, updateActions)); Assert.Single(updatedType.FieldDefinitions); Assert.IsType <StringFieldType>(updatedType.FieldDefinitions[0].Type); return(updatedType); }); }