public void UpdateCustomObject() { IClient commerceToolsClient = this.customObjectsFixture.GetService <IClient>(); FooBar fooBar = new FooBar(); string key = TestingUtility.RandomString(10); CustomObjectDraft <FooBar> customObjectDraft = this.customObjectsFixture.GetFooBarCustomObjectDraft(TestingUtility.DefaultContainerName, key, fooBar); //Create FooBar Custom Object var customObject = commerceToolsClient .ExecuteAsync(new CustomObjectUpsertCommand <FooBar>(customObjectDraft)).Result; Assert.Equal(customObjectDraft.Key, customObject.Key); Assert.Equal(customObjectDraft.Value.Bar, customObject.Value.Bar); //Then Update Custom Object Value customObjectDraft.Value.Bar = TestingUtility.RandomString(10); var updatedCustomObject = commerceToolsClient .ExecuteAsync(new CustomObjectUpsertCommand <FooBar>(customObjectDraft)).Result; this.customObjectsFixture.CustomObjectsToDelete.Add(updatedCustomObject); Assert.Equal(customObjectDraft.Key, updatedCustomObject.Key); Assert.Equal(customObjectDraft.Value.Bar, updatedCustomObject.Value.Bar); }
/// <summary> /// Create FooBar CustomObjects inside FooBarContainer /// </summary> public List <CustomObject <FooBar> > CreateMultipleFooBarCustomObjects(string container = TestingUtility.DefaultContainerName, int count = 3) { List <CustomObject <FooBar> > customObjects = new List <CustomObject <FooBar> >(); for (var i = 1; i <= count; i++) { var fooBar = new FooBar($"FooBar_{i}"); var fooBarDraft = GetFooBarCustomObjectDraft(container, TestingUtility.RandomString(10), fooBar); var fooBarCustomObject = CreateCustomObject(fooBarDraft); customObjects.Add(fooBarCustomObject); } return(customObjects); }
public CustomObject <FooBar> CreateFooBarCustomObject(string container = TestingUtility.DefaultContainerName, string key = null, FooBar fooBar = null) { key = key ?? TestingUtility.RandomString(10); fooBar = fooBar ?? new FooBar(); var draft = GetFooBarCustomObjectDraft(container, key, fooBar); return(CreateCustomObject(draft)); }
public CustomObjectDraft <FooBar> GetFooBarCustomObjectDraft(string container, string key, FooBar fooBar) { var draft = GetCustomObjectDraft(container, key, fooBar); return(draft); }