public async Task UpdateStateRemoveRoles()
        {
            var oldRoles = new List <StateRole> {
                StateRole.Return
            };

            await WithUpdateableState(client,
                                      stateDraft => DefaultStateDraftWithRoles(stateDraft, oldRoles),
                                      async state =>
            {
                Assert.Single(state.Roles);
                var removedRoles = new List <StateRole>
                {
                    StateRole.Return
                };
                var action = new RemoveRolesUpdateAction
                {
                    Roles = removedRoles
                };

                var updatedState = await client
                                   .ExecuteAsync(state.UpdateByKey(actions => actions.AddUpdate(action)));

                Assert.Empty(updatedState.Roles);
                return(updatedState);
            });
        }
Esempio n. 2
0
        public async Task UpdateChannelRemoveRoles()
        {
            await WithUpdateableChannel(client,
                                        channelDraft => DefaultChannelDraftWithRoles(channelDraft, new List <ChannelRole>
            {
                ChannelRole.InventorySupply,
                ChannelRole.ProductDistribution
            }),
                                        async channel =>
            {
                Assert.Equal(2, channel.Roles.Count);

                var removedRoles = new List <ChannelRole> {
                    ChannelRole.ProductDistribution
                };
                var updateActions = new List <UpdateAction <Channel> >();
                var action        = new RemoveRolesUpdateAction {
                    Roles = removedRoles
                };
                updateActions.Add(action);

                var updatedChannel = await client
                                     .ExecuteAsync(new UpdateByIdCommand <Channel>(channel, updateActions));

                Assert.Single(updatedChannel.Roles);
                Assert.Equal(ChannelRole.InventorySupply, updatedChannel.Roles[0]);
                return(updatedChannel);
            });
        }