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
diff --git a/Tests/LibMatrix.Tests/Config.cs b/Tests/LibMatrix.Tests/Config.cs
index fb4ef02..ddbf705 100644
--- a/Tests/LibMatrix.Tests/Config.cs
+++ b/Tests/LibMatrix.Tests/Config.cs
@@ -8,10 +8,11 @@ public class Config {
public string? TestRoomAlias { get; set; } = Environment.GetEnvironmentVariable("LIBMATRIX_TEST_ROOM_ALIAS") ?? null;
public Dictionary<string, string> ExpectedHomeserverMappings { get; set; } = new() {
- {"matrix.org", "https://matrix-client.matrix.org"},
- {"rory.gay", "https://matrix.rory.gay"}
+ { "matrix.org", "https://matrix-client.matrix.org" },
+ { "rory.gay", "https://matrix.rory.gay" }
};
+
public Dictionary<string, string> ExpectedAliasMappings { get; set; } = new() {
- {"#libmatrix:rory.gay", "!tuiLEoMqNOQezxILzt:rory.gay"}
+ { "#libmatrix:rory.gay", "!tuiLEoMqNOQezxILzt:rory.gay" }
};
-}
+}
\ No newline at end of file
diff --git a/Tests/LibMatrix.Tests/DataTests/WhoAmITests.cs b/Tests/LibMatrix.Tests/DataTests/WhoAmITests.cs
index 056cd3c..e1da3d5 100644
--- a/Tests/LibMatrix.Tests/DataTests/WhoAmITests.cs
+++ b/Tests/LibMatrix.Tests/DataTests/WhoAmITests.cs
@@ -7,4 +7,4 @@ public static class WhoAmITests {
if (!isAppservice)
Assert.NotNull(obj.DeviceId);
}
-}
+}
\ No newline at end of file
diff --git a/Tests/LibMatrix.Tests/Fixtures/TestFixture.cs b/Tests/LibMatrix.Tests/Fixtures/TestFixture.cs
index ef49b3e..35c8704 100644
--- a/Tests/LibMatrix.Tests/Fixtures/TestFixture.cs
+++ b/Tests/LibMatrix.Tests/Fixtures/TestFixture.cs
@@ -11,8 +11,8 @@ public class TestFixture : TestBedFixture {
protected override void AddServices(IServiceCollection services, IConfiguration? configuration) {
services.AddSingleton<TieredStorageService>(x =>
new TieredStorageService(
- cacheStorageProvider: null,
- dataStorageProvider: null
+ null,
+ null
)
);
@@ -34,4 +34,4 @@ public class TestFixture : TestBedFixture {
protected override IEnumerable<TestAppSettings> GetTestAppSettings() {
yield return new TestAppSettings { Filename = "appsettings.json", IsOptional = true };
}
-}
+}
\ No newline at end of file
diff --git a/Tests/LibMatrix.Tests/GlobalUsings.cs b/Tests/LibMatrix.Tests/GlobalUsings.cs
index c802f44..8c927eb 100644
--- a/Tests/LibMatrix.Tests/GlobalUsings.cs
+++ b/Tests/LibMatrix.Tests/GlobalUsings.cs
@@ -1 +1 @@
-global using Xunit;
+global using Xunit;
\ No newline at end of file
diff --git a/Tests/LibMatrix.Tests/LibMatrix.Tests.csproj b/Tests/LibMatrix.Tests/LibMatrix.Tests.csproj
index 3f7bc87..d833d8b 100644
--- a/Tests/LibMatrix.Tests/LibMatrix.Tests.csproj
+++ b/Tests/LibMatrix.Tests/LibMatrix.Tests.csproj
@@ -10,11 +10,11 @@
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
-
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0-preview-23531-01" />
- <PackageReference Include="xunit" Version="2.6.1" />
- <PackageReference Include="Xunit.Microsoft.DependencyInjection" Version="7.0.10" />
+ <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0"/>
+
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0-preview-23531-01"/>
+ <PackageReference Include="xunit" Version="2.6.1"/>
+ <PackageReference Include="Xunit.Microsoft.DependencyInjection" Version="7.0.10"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
@@ -23,11 +23,11 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
- <PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
+ <PackageReference Include="Xunit.SkippableFact" Version="1.4.13"/>
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\..\LibMatrix\LibMatrix.csproj" />
+ <ProjectReference Include="..\..\LibMatrix\LibMatrix.csproj"/>
</ItemGroup>
<ItemGroup>
@@ -35,5 +35,5 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
-
+
</Project>
diff --git a/Tests/LibMatrix.Tests/Tests/AuthTests.cs b/Tests/LibMatrix.Tests/Tests/AuthTests.cs
index 5476b84..67ba8eb 100644
--- a/Tests/LibMatrix.Tests/Tests/AuthTests.cs
+++ b/Tests/LibMatrix.Tests/Tests/AuthTests.cs
@@ -68,4 +68,4 @@ public class AuthTests : TestBed<TestFixture> {
Assert.NotNull(hs.AccessToken);
await hs.Logout();
}
-}
+}
\ No newline at end of file
diff --git a/Tests/LibMatrix.Tests/Tests/ResolverTest.cs b/Tests/LibMatrix.Tests/Tests/ResolverTest.cs
index 804ad6c..700aa96 100644
--- a/Tests/LibMatrix.Tests/Tests/ResolverTest.cs
+++ b/Tests/LibMatrix.Tests/Tests/ResolverTest.cs
@@ -10,6 +10,7 @@ public class ResolverTest : TestBed<TestFixture> {
private readonly HomeserverResolverService _resolver;
private readonly Config _config;
private readonly HomeserverProviderService _provider;
+
public ResolverTest(ITestOutputHelper testOutputHelper, TestFixture fixture) : base(testOutputHelper, fixture) {
_fixture = fixture;
_resolver = _fixture.GetService<HomeserverResolverService>(_testOutputHelper) ?? throw new InvalidOperationException($"Failed to get {nameof(HomeserverResolverService)}");
@@ -51,4 +52,4 @@ public class ResolverTest : TestBed<TestFixture> {
var profile = await hs.GetProfileAsync("@alice-is-:matrix.org");
Assert.NotNull(profile);
}
-}
+}
\ No newline at end of file
diff --git a/Tests/LibMatrix.Tests/Tests/RoomEventTests.cs b/Tests/LibMatrix.Tests/Tests/RoomEventTests.cs
index 060e6f2..932909f 100644
--- a/Tests/LibMatrix.Tests/Tests/RoomEventTests.cs
+++ b/Tests/LibMatrix.Tests/Tests/RoomEventTests.cs
@@ -20,9 +20,7 @@ public class RoomEventTests : TestBed<TestFixture> {
_provider = _fixture.GetService<HomeserverProviderService>(_testOutputHelper) ?? throw new InvalidOperationException($"Failed to get {nameof(HomeserverProviderService)}");
}
- private async Task<AuthenticatedHomeserverGeneric> GetHomeserver() {
- return await HomeserverAbstraction.GetHomeserver();
- }
+ private async Task<AuthenticatedHomeserverGeneric> GetHomeserver() => await HomeserverAbstraction.GetHomeserver();
[Fact]
public async Task GetNameAsync() {
@@ -153,5 +151,4 @@ public class RoomEventTests : TestBed<TestFixture> {
Assert.NotNull(power.Users);
// Assert.NotNull(power.Events);
}
-
-}
+}
\ No newline at end of file
diff --git a/Tests/LibMatrix.Tests/Tests/RoomTests.cs b/Tests/LibMatrix.Tests/Tests/RoomTests.cs
index bec8d18..4f7ac17 100644
--- a/Tests/LibMatrix.Tests/Tests/RoomTests.cs
+++ b/Tests/LibMatrix.Tests/Tests/RoomTests.cs
@@ -23,9 +23,7 @@ public class RoomTests : TestBed<TestFixture> {
_provider = _fixture.GetService<HomeserverProviderService>(_testOutputHelper) ?? throw new InvalidOperationException($"Failed to get {nameof(HomeserverProviderService)}");
}
- private async Task<AuthenticatedHomeserverGeneric> GetHomeserver() {
- return await HomeserverAbstraction.GetHomeserver();
- }
+ private async Task<AuthenticatedHomeserverGeneric> GetHomeserver() => await HomeserverAbstraction.GetHomeserver();
[Fact]
public async Task GetJoinedRoomsAsync() {
@@ -43,7 +41,6 @@ public class RoomTests : TestBed<TestFixture> {
await hs.Logout();
}
-
[Fact]
public async Task GetMembersAsync() {
Assert.True(StateEvent.KnownStateEventTypes is { Count: > 0 }, "StateEvent.KnownStateEventTypes is empty!");
@@ -54,7 +51,7 @@ public class RoomTests : TestBed<TestFixture> {
Assert.NotNull(room);
var members = room.GetMembersEnumerableAsync();
Assert.NotNull(members);
- bool hitMembers = false;
+ var hitMembers = false;
await foreach (var member in members) {
Assert.NotNull(member);
Assert.NotNull(member.StateKey);
@@ -211,7 +208,7 @@ public class RoomTests : TestBed<TestFixture> {
Assert.NotNull(room);
var res = await room.SendFileAsync("test.txt", new MemoryStream(Encoding.UTF8.GetBytes("This test was written by Emma [it/its], member of the Rory& system." +
- "\nIf you are reading this on matrix, it means the unit test for uploading a file works!")));
+ "\nIf you are reading this on matrix, it means the unit test for uploading a file works!")));
Assert.NotNull(res);
Assert.NotNull(res.EventId);
}
@@ -223,10 +220,8 @@ public class RoomTests : TestBed<TestFixture> {
Assert.NotNull(space);
var children = space.GetChildrenAsync();
Assert.NotNull(children);
- int found = 0;
- await foreach (var room in children) {
- found++;
- }
+ var found = 0;
+ await foreach (var room in children) found++;
Assert.Equal(2, found);
}
@@ -240,15 +235,14 @@ public class RoomTests : TestBed<TestFixture> {
// var expectedCount = 1;
var tasks = new List<Task>();
- await foreach (var otherUser in otherUsers) {
+ await foreach (var otherUser in otherUsers)
tasks.Add(Task.Run(async () => {
await room.InviteUserAsync(otherUser.UserId);
await otherUser.GetRoom(room.RoomId).JoinAsync();
}));
- }
await Task.WhenAll(tasks);
var states = await room.GetMembersListAsync(false);
Assert.Equal(16, states.Count);
}
-}
+}
\ No newline at end of file
diff --git a/Tests/LibMatrix.Tests/Tests/TestCleanup.cs b/Tests/LibMatrix.Tests/Tests/TestCleanup.cs
index d056345..7fc7c64 100644
--- a/Tests/LibMatrix.Tests/Tests/TestCleanup.cs
+++ b/Tests/LibMatrix.Tests/Tests/TestCleanup.cs
@@ -71,4 +71,4 @@ public class TestCleanup : TestBed<TestFixture> {
Assert.NotNull(hs);
await hs.Logout();
}
-}
+}
\ No newline at end of file
diff --git a/Tests/TestDataGenerator/Bot/DataFetcher.cs b/Tests/TestDataGenerator/Bot/DataFetcher.cs
index 5e8c1a1..66b8a03 100644
--- a/Tests/TestDataGenerator/Bot/DataFetcher.cs
+++ b/Tests/TestDataGenerator/Bot/DataFetcher.cs
@@ -36,19 +36,18 @@ public class DataFetcher(AuthenticatedHomeserverGeneric hs, ILogger<DataFetcher>
var roomAliasTasks = rooms.Select(room => room.GetCanonicalAliasAsync()).ToAsyncEnumerable();
List<Task<(string, string)>> aliasResolutionTasks = new();
- await foreach (var @event in roomAliasTasks) {
+ await foreach (var @event in roomAliasTasks)
if (@event?.Alias != null) {
- await _logRoom.SendMessageEventAsync(new RoomMessageEventContent(body: $"Fetched room alias {(@event).Alias}!"));
+ await _logRoom.SendMessageEventAsync(new RoomMessageEventContent(body: $"Fetched room alias {@event.Alias}!"));
aliasResolutionTasks.Add(Task.Run(async () => {
var alias = await hs.ResolveRoomAliasAsync(@event.Alias);
return (@event.Alias, alias.RoomId);
}, cancellationToken));
}
- }
+
var aliasResolutionTaskEnumerator = aliasResolutionTasks.ToAsyncEnumerable();
- await foreach (var result in aliasResolutionTaskEnumerator) {
+ await foreach (var result in aliasResolutionTaskEnumerator)
await _logRoom.SendMessageEventAsync(new RoomMessageEventContent(body: $"Resolved room alias {result.Item1} to {result.Item2}!"));
- }
}
/// <summary>Triggered when the application host is performing a graceful shutdown.</summary>
@@ -57,4 +56,4 @@ public class DataFetcher(AuthenticatedHomeserverGeneric hs, ILogger<DataFetcher>
logger.LogInformation("Shutting down bot!");
_listenerTask?.Dispose();
}
-}
+}
\ No newline at end of file
diff --git a/Tests/TestDataGenerator/Bot/DataFetcherConfiguration.cs b/Tests/TestDataGenerator/Bot/DataFetcherConfiguration.cs
index a586d05..4f53a2a 100644
--- a/Tests/TestDataGenerator/Bot/DataFetcherConfiguration.cs
+++ b/Tests/TestDataGenerator/Bot/DataFetcherConfiguration.cs
@@ -6,4 +6,4 @@ public class DataFetcherConfiguration {
public DataFetcherConfiguration(IConfiguration config) => config.GetRequiredSection("DataFetcher").Bind(this);
// public string
-}
+}
\ No newline at end of file
diff --git a/Tests/TestDataGenerator/Program.cs b/Tests/TestDataGenerator/Program.cs
index 5d36215..5c20958 100644
--- a/Tests/TestDataGenerator/Program.cs
+++ b/Tests/TestDataGenerator/Program.cs
@@ -11,17 +11,17 @@ Console.WriteLine("Hello, World!");
var host = Host.CreateDefaultBuilder(args).ConfigureServices((_, services) => {
services.AddScoped<TieredStorageService>(_ =>
new TieredStorageService(
- cacheStorageProvider: new FileStorageProvider("bot_data/cache/"),
- dataStorageProvider: new FileStorageProvider("bot_data/data/")
+ new FileStorageProvider("bot_data/cache/"),
+ new FileStorageProvider("bot_data/data/")
)
);
// services.AddSingleton<DataFetcherConfiguration>();
services.AddSingleton<AppServiceConfiguration>();
services.AddRoryLibMatrixServices();
- services.AddBot(withCommands: false);
+ services.AddBot(false);
services.AddHostedService<DataFetcher>();
}).UseConsoleLifetime().Build();
-await host.RunAsync();
+await host.RunAsync();
\ No newline at end of file
diff --git a/Tests/TestDataGenerator/Properties/launchSettings.json b/Tests/TestDataGenerator/Properties/launchSettings.json
index 997e294..6c504ff 100644
--- a/Tests/TestDataGenerator/Properties/launchSettings.json
+++ b/Tests/TestDataGenerator/Properties/launchSettings.json
@@ -5,7 +5,6 @@
"commandName": "Project",
"dotnetRunMessages": true,
"environmentVariables": {
-
}
},
"Development": {
diff --git a/Tests/TestDataGenerator/TestDataGenerator.csproj b/Tests/TestDataGenerator/TestDataGenerator.csproj
index cf212de..879693e 100644
--- a/Tests/TestDataGenerator/TestDataGenerator.csproj
+++ b/Tests/TestDataGenerator/TestDataGenerator.csproj
@@ -17,7 +17,7 @@
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0"/>
</ItemGroup>
<ItemGroup>
<Content Include="appsettings*.json">
@@ -25,8 +25,8 @@
</Content>
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\..\LibMatrix\LibMatrix.csproj" />
- <ProjectReference Include="..\..\Utilities\LibMatrix.Utilities.Bot\LibMatrix.Utilities.Bot.csproj" />
- <ProjectReference Include="..\LibMatrix.Tests\LibMatrix.Tests.csproj" />
+ <ProjectReference Include="..\..\LibMatrix\LibMatrix.csproj"/>
+ <ProjectReference Include="..\..\Utilities\LibMatrix.Utilities.Bot\LibMatrix.Utilities.Bot.csproj"/>
+ <ProjectReference Include="..\LibMatrix.Tests\LibMatrix.Tests.csproj"/>
</ItemGroup>
</Project>
diff --git a/Tests/TestDataGenerator/appsettings.json b/Tests/TestDataGenerator/appsettings.json
index 6ba02f3..e203e94 100644
--- a/Tests/TestDataGenerator/appsettings.json
+++ b/Tests/TestDataGenerator/appsettings.json
@@ -1,9 +1,9 @@
{
- "Logging": {
- "LogLevel": {
- "Default": "Debug",
- "System": "Information",
- "Microsoft": "Information"
- }
+ "Logging": {
+ "LogLevel": {
+ "Default": "Debug",
+ "System": "Information",
+ "Microsoft": "Information"
}
+ }
}
|