about summary refs log tree commit diff
path: root/Tests/LibMatrix.Tests/Abstractions
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Tests/LibMatrix.Tests/Abstractions/HomeserverAbstraction.cs12
-rw-r--r--Tests/LibMatrix.Tests/Abstractions/RoomAbstraction.cs29
2 files changed, 18 insertions, 23 deletions
diff --git a/Tests/LibMatrix.Tests/Abstractions/HomeserverAbstraction.cs b/Tests/LibMatrix.Tests/Abstractions/HomeserverAbstraction.cs
index 8a976a7..c9727d6 100644
--- a/Tests/LibMatrix.Tests/Abstractions/HomeserverAbstraction.cs
+++ b/Tests/LibMatrix.Tests/Abstractions/HomeserverAbstraction.cs
@@ -9,8 +9,8 @@ public static class HomeserverAbstraction {
         var rhs = await RemoteHomeserver.Create("https://matrixunittests.rory.gay");
         // string username = Guid.NewGuid().ToString();
         // string password = Guid.NewGuid().ToString();
-        string username = "@f1a2d2d6-1924-421b-91d0-893b347b2a49:matrixunittests.rory.gay";
-        string password = "d6d782d6-8bc9-4fac-9cd8-78e101b4298b";
+        var username = "@f1a2d2d6-1924-421b-91d0-893b347b2a49:matrixunittests.rory.gay";
+        var password = "d6d782d6-8bc9-4fac-9cd8-78e101b4298b";
         LoginResponse reg;
         try {
             reg = await rhs.LoginAsync(username, password);
@@ -46,7 +46,7 @@ public static class HomeserverAbstraction {
 
     public static async Task<AuthenticatedHomeserverGeneric> GetRandomHomeserver() {
         var rhs = await RemoteHomeserver.Create("https://matrixunittests.rory.gay");
-        LoginResponse reg = await rhs.RegisterAsync(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "Unit tests!");
+        var reg = await rhs.RegisterAsync(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "Unit tests!");
         var hs = await reg.GetAuthenticatedHomeserver("https://matrixunittests.rory.gay");
 
         // var rooms = await hs.GetJoinedRooms();
@@ -66,8 +66,6 @@ public static class HomeserverAbstraction {
         var createRandomUserTasks = Enumerable
             .Range(0, count)
             .Select(_ => GetRandomHomeserver()).ToAsyncEnumerable();
-        await foreach (var hs in createRandomUserTasks) {
-            yield return hs;
-        }
+        await foreach (var hs in createRandomUserTasks) yield return hs;
     }
-}
+}
\ No newline at end of file
diff --git a/Tests/LibMatrix.Tests/Abstractions/RoomAbstraction.cs b/Tests/LibMatrix.Tests/Abstractions/RoomAbstraction.cs
index 0cbcf75..2a380fc 100644
--- a/Tests/LibMatrix.Tests/Abstractions/RoomAbstraction.cs
+++ b/Tests/LibMatrix.Tests/Abstractions/RoomAbstraction.cs
@@ -14,7 +14,7 @@ public static class RoomAbstraction {
             // Visibility = CreateRoomVisibility.Public,
             RoomAliasName = Guid.NewGuid().ToString()
         };
-        crq.InitialState ??= new();
+        crq.InitialState ??= new List<StateEvent>();
         crq.InitialState.Add(new StateEvent() {
             Type = "m.room.topic",
             StateKey = "",
@@ -47,7 +47,7 @@ public static class RoomAbstraction {
         });
         var testRoom = await hs.CreateRoom(crq);
 
-        await testRoom.SendStateEventAsync("gay.rory.libmatrix.unit_test_room", new());
+        await testRoom.SendStateEventAsync("gay.rory.libmatrix.unit_test_room", new object());
 
         return testRoom;
     }
@@ -55,16 +55,15 @@ public static class RoomAbstraction {
     private static SemaphoreSlim _spaceSemaphore = null!;
 
     public static async Task<SpaceRoom> GetTestSpace(AuthenticatedHomeserverGeneric hs, int roomCount = 100, bool addSpaces = false, int spaceSizeReduction = 10) {
-        _spaceSemaphore ??= new(roomCount / spaceSizeReduction, roomCount / spaceSizeReduction);
+        _spaceSemaphore ??= new SemaphoreSlim(roomCount / spaceSizeReduction, roomCount / spaceSizeReduction);
         var crq = new CreateRoomRequest() {
             Name = $"LibMatrix Test Space ({roomCount} children)",
             // Visibility = CreateRoomVisibility.Public,
             RoomAliasName = Guid.NewGuid().ToString(),
-            InitialState = new()
+            InitialState = new List<StateEvent>()
         };
         crq.CreationContentBaseType.Type = "m.space";
 
-
         var createRoomTasks = Enumerable.Range(0, roomCount)
             .Select(_ => hs.CreateRoom(new CreateRoomRequest() {
                 Name = $"LibMatrix Test Room {Guid.NewGuid()}",
@@ -72,38 +71,36 @@ public static class RoomAbstraction {
                 RoomAliasName = Guid.NewGuid().ToString()
             })).ToAsyncEnumerable();
 
-        await foreach (var room in createRoomTasks) {
-            crq.InitialState.Add(new() {
+        await foreach (var room in createRoomTasks)
+            crq.InitialState.Add(new StateEvent {
                 Type = "m.space.child",
                 StateKey = room.RoomId,
                 TypedContent = new SpaceChildEventContent() {
-                    Via = new() {
+                    Via = new List<string> {
                         room.RoomId.Split(":")[1]
                     }
                 }
             });
-        }
 
-        if (addSpaces) {
-            for (int i = 0; i < roomCount; i++) {
+        if (addSpaces)
+            for (var i = 0; i < roomCount; i++) {
                 var space = await GetTestSpace(hs, roomCount - spaceSizeReduction, true, spaceSizeReduction);
-                crq.InitialState.Add(new() {
+                crq.InitialState.Add(new StateEvent {
                     Type = "m.space.child",
                     StateKey = space.RoomId,
                     TypedContent = new SpaceChildEventContent() {
-                        Via = new() {
+                        Via = new List<string> {
                             space.RoomId.Split(":")[1]
                         }
                     }
                 });
             }
-        }
 
         var testSpace = (await hs.CreateRoom(crq)).AsSpace;
 
-        await testSpace.SendStateEventAsync("gay.rory.libmatrix.unit_test_room", new());
+        await testSpace.SendStateEventAsync("gay.rory.libmatrix.unit_test_room", new object());
 
         // _spaceSemaphore.Release();
         return testSpace;
     }
-}
+}
\ No newline at end of file