Пример #1
0
        public async void UpdateOrderEditSetCustomType()
        {
            var fields = CreateNewFields();

            await WithType(client, async type =>
            {
                await WithSimpleOrder(client, async order =>
                {
                    await WithUpdateableOrderEdit(client,
                                                  draft => DefaultOrderEditDraftWithStagedAction(draft, order),
                                                  async orderEdit =>
                    {
                        Assert.NotNull(orderEdit);
                        Assert.Single(orderEdit.StagedActions);

                        var action = new SetCustomTypeUpdateAction
                        {
                            Type   = type.ToKeyResourceIdentifier(),
                            Fields = fields
                        };

                        var updatedOrderEdit = await client
                                               .ExecuteAsync(orderEdit.UpdateById(
                                                                 actions => actions.AddUpdate(action)));

                        Assert.Equal(type.Id, updatedOrderEdit.Custom.Type.Id);
                        return(updatedOrderEdit);
                    });
                });
            });
        }
Пример #2
0
        public async void UpdateOrderEditSetCustomField()
        {
            var fields   = CreateNewFields();
            var newValue = TestingUtility.RandomString();

            await WithType(client, async type =>
            {
                await WithSimpleOrder(client, async order =>
                {
                    await WithUpdateableOrderEdit(client,
                                                  draft => DefaultOrderEditDraftWithStagedAction(draft, order),
                                                  async orderEdit =>
                    {
                        Assert.NotNull(orderEdit);
                        Assert.Single(orderEdit.StagedActions);

                        var action = new SetCustomTypeUpdateAction
                        {
                            Type   = type.ToKeyResourceIdentifier(),
                            Fields = fields
                        };

                        var updatedOrderEdit = await client
                                               .ExecuteAsync(orderEdit.UpdateById(
                                                                 actions => actions.AddUpdate(action)));

                        Assert.Equal(type.Id, updatedOrderEdit.Custom.Type.Id);

                        //then set the custom field
                        var setFieldAction = new SetCustomFieldUpdateAction()
                        {
                            Name = "string-field", Value = newValue
                        };
                        var updatedOrderEditWithUpdatedCustomField = await client
                                                                     .ExecuteAsync(updatedOrderEdit.UpdateById(
                                                                                       actions => actions.AddUpdate(setFieldAction)));

                        Assert.Equal(newValue,
                                     updatedOrderEditWithUpdatedCustomField.Custom.Fields["string-field"]);

                        return(updatedOrderEditWithUpdatedCustomField);
                    });
                });
            });
        }