本文整理汇总了C#中JabbR.Services.ChatService.KickUser方法的典型用法代码示例。如果您正苦于以下问题:C# ChatService.KickUser方法的具体用法?C# ChatService.KickUser怎么用?C# ChatService.KickUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JabbR.Services.ChatService
的用法示例。
在下文中一共展示了ChatService.KickUser方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ThrowsIfUserIsNotOwner
public void ThrowsIfUserIsNotOwner()
{
var repository = new InMemoryRepository();
var user = new ChatUser
{
Name = "foo"
};
var user2 = new ChatUser
{
Name = "foo2"
};
repository.Add(user);
repository.Add(user2);
var room = new ChatRoom
{
Name = "Room",
};
user.Rooms.Add(room);
user2.Rooms.Add(room);
room.Users.Add(user);
room.Users.Add(user2);
var service = new ChatService(repository);
Assert.Throws<InvalidOperationException>(() => service.KickUser(user, user2, room));
}
示例2: DoesNotThrowIfCreatorKicksOwner
public void DoesNotThrowIfCreatorKicksOwner()
{
var repository = new InMemoryRepository();
var user = new ChatUser
{
Name = "foo"
};
var user2 = new ChatUser
{
Name = "foo2"
};
repository.Add(user);
repository.Add(user2);
var room = new ChatRoom
{
Name = "Room",
Creator = user
};
user.OwnedRooms.Add(room);
room.Owners.Add(user);
user2.OwnedRooms.Add(room);
room.Owners.Add(user2);
user.Rooms.Add(room);
user2.Rooms.Add(room);
room.Users.Add(user);
room.Users.Add(user2);
var service = new ChatService(repository);
service.KickUser(user, user2, room);
Assert.False(user2.Rooms.Contains(room));
Assert.False(room.Users.Contains(user2));
}
示例3: ThrowsIfKickSelf
public void ThrowsIfKickSelf()
{
var repository = new InMemoryRepository();
var user = new ChatUser
{
Name = "foo"
};
repository.Add(user);
var room = new ChatRoom
{
Name = "Room",
Creator = user
};
room.Owners.Add(user);
user.OwnedRooms.Add(room);
user.Rooms.Add(room);
room.Users.Add(user);
var service = new ChatService(repository);
Assert.Throws<InvalidOperationException>(() => service.KickUser(user, user, room));
}
示例4: ThrowsIfUserIsNotOwnerAndNotAdmin
public void ThrowsIfUserIsNotOwnerAndNotAdmin()
{
var repository = new InMemoryRepository();
var user = new ChatUser
{
Name = "foo"
};
var user2 = new ChatUser
{
Name = "foo2"
};
repository.Add(user);
repository.Add(user2);
var room = new ChatRoom
{
Name = "Room",
};
user.Rooms.Add(room);
user2.Rooms.Add(room);
room.Users.Add(user);
room.Users.Add(user2);
var service = new ChatService(new Mock<ICache>().Object, repository);
Assert.Throws<HubException>(() => service.KickUser(user, user2, room));
}
示例5: ThrowsIfOwnerTriesToRemoveOwner
public void ThrowsIfOwnerTriesToRemoveOwner()
{
var repository = new InMemoryRepository();
var user = new ChatUser
{
Name = "foo"
};
var user2 = new ChatUser
{
Name = "foo2"
};
repository.Add(user);
repository.Add(user2);
var room = new ChatRoom
{
Name = "Room",
};
user.OwnedRooms.Add(room);
room.Owners.Add(user);
user2.OwnedRooms.Add(room);
room.Owners.Add(user2);
user.Rooms.Add(room);
user2.Rooms.Add(room);
room.Users.Add(user);
room.Users.Add(user2);
var service = new ChatService(repository, new Mock<ICryptoService>().Object);
Assert.Throws<InvalidOperationException>(() => service.KickUser(user, user2, room));
}
示例6: ThrowsIfOwnerTriesToRemoveAdmin
public void ThrowsIfOwnerTriesToRemoveAdmin()
{
var repository = new InMemoryRepository();
var admin = new ChatUser
{
Name = "foo",
IsAdmin = true
};
var owner = new ChatUser
{
Name = "foo2"
};
repository.Add(admin);
repository.Add(owner);
var room = new ChatRoom
{
Name = "Room",
};
owner.OwnedRooms.Add(room);
room.Owners.Add(owner);
admin.Rooms.Add(room);
owner.Rooms.Add(room);
room.Users.Add(admin);
room.Users.Add(owner);
var service = new ChatService(new Mock<ICache>().Object, repository);
Assert.Throws<HubException>(() => service.KickUser(owner, admin, room));
}
示例7: ThrowsIfTargetUserNotInRoom
public void ThrowsIfTargetUserNotInRoom()
{
var repository = new InMemoryRepository();
var user = new ChatUser
{
Name = "foo"
};
var user2 = new ChatUser
{
Name = "foo2"
};
repository.Add(user);
repository.Add(user2);
var room = new ChatRoom
{
Name = "Room",
Creator = user
};
user.OwnedRooms.Add(room);
room.Owners.Add(user);
user.Rooms.Add(room);
room.Users.Add(user);
var service = new ChatService(new Mock<ICache>().Object, repository);
Assert.Throws<HubException>(() => service.KickUser(user, user2, room));
}
示例8: DoesNotThrowIfAdminKicksOwner
public void DoesNotThrowIfAdminKicksOwner()
{
var repository = new InMemoryRepository();
var admin = new ChatUser
{
Name = "foo",
IsAdmin = true
};
var user2 = new ChatUser
{
Name = "foo2"
};
repository.Add(admin);
repository.Add(user2);
var room = new ChatRoom
{
Name = "Room"
};
user2.OwnedRooms.Add(room);
room.Owners.Add(user2);
admin.Rooms.Add(room);
user2.Rooms.Add(room);
room.Users.Add(admin);
room.Users.Add(user2);
var service = new ChatService(new Mock<ICache>().Object, repository);
service.KickUser(admin, user2, room);
Assert.False(user2.Rooms.Contains(room));
Assert.False(room.Users.Contains(user2));
}
示例9: AdminCanKickCreator
public void AdminCanKickCreator()
{
var repository = new InMemoryRepository();
var admin = new ChatUser
{
Name = "foo",
IsAdmin = true
};
var creator = new ChatUser
{
Name = "foo2"
};
repository.Add(admin);
repository.Add(creator);
var room = new ChatRoom
{
Name = "Room",
Creator = creator
};
creator.OwnedRooms.Add(room);
room.Owners.Add(creator);
admin.Rooms.Add(room);
creator.Rooms.Add(room);
room.Users.Add(admin);
room.Users.Add(creator);
var service = new ChatService(new Mock<ICache>().Object, repository);
service.KickUser(admin, creator, room);
Assert.False(creator.Rooms.Contains(room));
Assert.False(room.Users.Contains(creator));
}
示例10: AdminCanKickAdmin
public void AdminCanKickAdmin()
{
var repository = new InMemoryRepository();
var admin = new ChatUser
{
Name = "foo",
IsAdmin = true
};
var otherAdmin = new ChatUser
{
Name = "foo2",
IsAdmin = true
};
repository.Add(admin);
repository.Add(otherAdmin);
var room = new ChatRoom
{
Name = "Room"
};
admin.Rooms.Add(room);
otherAdmin.Rooms.Add(room);
room.Users.Add(admin);
room.Users.Add(otherAdmin);
var service = new ChatService(new Mock<ICache>().Object, repository);
service.KickUser(admin, otherAdmin, room);
Assert.False(otherAdmin.Rooms.Contains(room));
Assert.False(room.Users.Contains(otherAdmin));
}
示例11: AdminCanKickUser
public void AdminCanKickUser()
{
var repository = new InMemoryRepository();
var admin = new ChatUser
{
Name = "foo",
IsAdmin = true
};
var user2 = new ChatUser
{
Name = "foo2"
};
repository.Add(admin);
repository.Add(user2);
var room = new ChatRoom
{
Name = "Room",
};
admin.Rooms.Add(room);
user2.Rooms.Add(room);
room.Users.Add(admin);
room.Users.Add(user2);
var service = new ChatService(repository, new Mock<ICryptoService>().Object);
service.KickUser(admin, user2, room);
Assert.False(user2.Rooms.Contains(room));
Assert.False(room.Users.Contains(user2));
}
示例12: ThrowsIfOwnerTriesToRemoveOwner
public void ThrowsIfOwnerTriesToRemoveOwner()
{
var repository = new InMemoryRepository();
var user = new ChatUser
{
Name = "foo"
};
var user2 = new ChatUser
{
Name = "foo2"
};
repository.Add(user);
repository.Add(user2);
var room = new ChatRoom
{
Name = "Room",
};
user.OwnedRooms.Add(room);
room.Owners.Add(user);
user2.OwnedRooms.Add(room);
room.Owners.Add(user2);
user.Rooms.Add(room);
user2.Rooms.Add(room);
room.Users.Add(user);
room.Users.Add(user2);
var service = new ChatService(new Mock<ICache>().Object, new Mock<IRecentMessageCache>().Object, repository);
Assert.Throws<HubException>(() => service.KickUser(user, user2, room));
}