diff options
Diffstat (limited to '')
-rw-r--r-- | Tests/LibMatrix.Tests/Tests/RoomTests.cs | 145 |
1 files changed, 10 insertions, 135 deletions
diff --git a/Tests/LibMatrix.Tests/Tests/RoomTests.cs b/Tests/LibMatrix.Tests/Tests/RoomTests.cs index 17c219d..72a2775 100644 --- a/Tests/LibMatrix.Tests/Tests/RoomTests.cs +++ b/Tests/LibMatrix.Tests/Tests/RoomTests.cs @@ -31,38 +31,18 @@ public class RoomTests : TestBed<TestFixture> { public async Task GetJoinedRoomsAsync() { var hs = await HomeserverAbstraction.GetHomeserver(); //make 100 rooms - var createRoomTasks = Enumerable.Range(0, 100).Select(_ => RoomAbstraction.GetTestRoom(hs)).ToList(); + var createRoomTasks = Enumerable.Range(0, 10).Select(_ => RoomAbstraction.GetTestRoom(hs)).ToList(); await Task.WhenAll(createRoomTasks); var rooms = await hs.GetJoinedRooms(); Assert.NotNull(rooms); Assert.NotEmpty(rooms); Assert.All(rooms, Assert.NotNull); - Assert.Equal(100, rooms.Count); + Assert.True(rooms.Count >= 10, "Not enough rooms were found"); await hs.Logout(); } - [Fact] - public async Task GetNameAsync() { - var hs = await HomeserverAbstraction.GetHomeserver(); - var room = await RoomAbstraction.GetTestRoom(hs); - Assert.NotNull(room); - var name = await room.GetNameAsync(); - Assert.NotNull(name); - Assert.NotEmpty(name); - } - - [SkippableFact(typeof(MatrixException))] - public async Task GetTopicAsync() { - var hs = await HomeserverAbstraction.GetHomeserver(); - var room = await RoomAbstraction.GetTestRoom(hs); - Assert.NotNull(room); - var topic = await room.GetTopicAsync(); - Assert.NotNull(topic); - Assert.NotNull(topic.Topic); - Assert.NotEmpty(topic.Topic); - } [Fact] public async Task GetMembersAsync() { @@ -106,115 +86,6 @@ public class RoomTests : TestBed<TestFixture> { Assert.NotEmpty(id.RoomId); } - [SkippableFact(typeof(MatrixException))] - public async Task GetAliasesAsync() { - var hs = await HomeserverAbstraction.GetHomeserver(); - var room = await RoomAbstraction.GetTestRoom(hs); - Assert.NotNull(room); - var aliases = await room.GetAliasesAsync(); - Assert.NotNull(aliases); - Assert.NotEmpty(aliases); - Assert.All(aliases, Assert.NotNull); - } - - [SkippableFact(typeof(MatrixException))] - public async Task GetCanonicalAliasAsync() { - var hs = await HomeserverAbstraction.GetHomeserver(); - var room = await RoomAbstraction.GetTestRoom(hs); - Assert.NotNull(room); - var alias = await room.GetCanonicalAliasAsync(); - Assert.NotNull(alias); - Assert.NotNull(alias.Alias); - Assert.NotEmpty(alias.Alias); - } - - [SkippableFact(typeof(MatrixException))] - public async Task GetAvatarUrlAsync() { - var hs = await HomeserverAbstraction.GetHomeserver(); - var room = await RoomAbstraction.GetTestRoom(hs); - Assert.NotNull(room); - var url = await room.GetAvatarUrlAsync(); - Assert.NotNull(url); - Assert.NotNull(url.Url); - Assert.NotEmpty(url.Url); - } - - [Fact] - public async Task GetJoinRuleAsync() { - var hs = await HomeserverAbstraction.GetHomeserver(); - var room = await RoomAbstraction.GetTestRoom(hs); - Assert.NotNull(room); - var rule = await room.GetJoinRuleAsync(); - Assert.NotNull(rule); - Assert.NotNull(rule.JoinRule); - Assert.NotEmpty(rule.JoinRule); - } - - [Fact] - public async Task GetHistoryVisibilityAsync() { - var hs = await HomeserverAbstraction.GetHomeserver(); - var room = await RoomAbstraction.GetTestRoom(hs); - Assert.NotNull(room); - var visibility = await room.GetHistoryVisibilityAsync(); - Assert.NotNull(visibility); - Assert.NotNull(visibility.HistoryVisibility); - Assert.NotEmpty(visibility.HistoryVisibility); - } - - [Fact] - public async Task GetGuestAccessAsync() { - var hs = await HomeserverAbstraction.GetHomeserver(); - var room = await RoomAbstraction.GetTestRoom(hs); - Assert.NotNull(room); - try { - var access = await room.GetGuestAccessAsync(); - Assert.NotNull(access); - Assert.NotNull(access.GuestAccess); - Assert.NotEmpty(access.GuestAccess); - } - catch (Exception e) { - if (e is not MatrixException exception) throw; - Assert.Equal("M_NOT_FOUND", exception.ErrorCode); - } - } - - [Fact] - public async Task GetCreateEventAsync() { - var hs = await HomeserverAbstraction.GetHomeserver(); - var room = await RoomAbstraction.GetTestRoom(hs); - Assert.NotNull(room); - var create = await room.GetCreateEventAsync(); - Assert.NotNull(create); - Assert.NotNull(create.Creator); - Assert.NotEmpty(create.RoomVersion!); - } - - [Fact] - public async Task GetRoomType() { - var hs = await HomeserverAbstraction.GetHomeserver(); - var room = await RoomAbstraction.GetTestRoom(hs); - Assert.NotNull(room); - await room.GetRoomType(); - } - - [Fact] - public async Task GetPowerLevelsAsync() { - var hs = await HomeserverAbstraction.GetHomeserver(); - var room = await RoomAbstraction.GetTestRoom(hs); - Assert.NotNull(room); - var power = await room.GetPowerLevelsAsync(); - Assert.NotNull(power); - Assert.NotNull(power.Ban); - Assert.NotNull(power.Kick); - Assert.NotNull(power.Invite); - Assert.NotNull(power.Redact); - Assert.NotNull(power.StateDefault); - Assert.NotNull(power.EventsDefault); - Assert.NotNull(power.UsersDefault); - Assert.NotNull(power.Users); - // Assert.NotNull(power.Events); - } - [Fact] public async Task ForgetAsync() { var hs = await HomeserverAbstraction.GetHomeserver(); @@ -361,17 +232,21 @@ public class RoomTests : TestBed<TestFixture> { [Fact] public async Task InviteAndJoinAsync() { - var otherUsers = HomeserverAbstraction.GetRandomHomeservers(7); var hs = await HomeserverAbstraction.GetHomeserver(); var room = await RoomAbstraction.GetTestRoom(hs); + var otherUsers = HomeserverAbstraction.GetRandomHomeservers(15); Assert.NotNull(room); // var expectedCount = 1; + var tasks = new List<Task>(); await foreach(var otherUser in otherUsers) { - await room.InviteUserAsync(otherUser.UserId); - await otherUser.GetRoom(room.RoomId).JoinAsync(); + tasks.Add(Task.Run(async () => { + await room.InviteUserAsync(otherUser.UserId); + await otherUser.GetRoom(room.RoomId).JoinAsync(); + })); } + await Task.WhenAll(tasks); var states = room.GetMembersAsync(false); var count = 0; @@ -379,6 +254,6 @@ public class RoomTests : TestBed<TestFixture> { count++; } // Assert.Equal(++expectedCount, count); - Assert.Equal(8, count); + Assert.Equal(16, count); } } |