コード例 #1
0
        public void DeleteChannelUserIsIn()
        {
            permissions.EnablePermissions(user.UserId, PermissionName.ChangeChannel);

            Assert.AreEqual(ChannelEditResult.Success, channels.SaveChannel(new ChannelInfo {
                Name = "Channel 2"
            }));
            client.DequeueAndAssertMessage <ChannelListMessage>();

            var channel = channels.GetChannels().Single(c => c.Name == "Channel 2");

            context.Users.Move(server, user, channel);
            client.DequeueAndAssertMessage <UserChangedChannelMessage>();

            permissions.EnablePermissions(user.UserId, PermissionName.DeleteChannel, PermissionName.RequestChannelList);

            handler.ChannelEditMessage(new MessageEventArgs <ChannelEditMessage> (server, new ChannelEditMessage
            {
                Channel = channel,
                Delete  = true
            }));

            var moved = client.DequeueAndAssertMessage <UserChangedChannelMessage>();

            Assert.AreEqual(user.UserId, moved.ChangeInfo.TargetUserId);
            Assert.AreEqual(channels.GetChannels().Single().ChannelId, moved.ChangeInfo.TargetChannelId);
            Assert.AreEqual(channel.ChannelId, moved.ChangeInfo.PreviousChannelId);
            Assert.AreEqual(0, moved.ChangeInfo.RequestingUserId);

            client.DequeueAndAssertMessage <ChannelListMessage>();

            var result = client.DequeueAndAssertMessage <ChannelEditResultMessage>();

            Assert.AreEqual(channel.ChannelId, result.ChannelId);
            Assert.AreEqual(ChannelEditResult.Success, result.Result);
        }