diff options
Diffstat (limited to 'ModerationClient/Services/TestRunner.cs')
-rw-r--r-- | ModerationClient/Services/TestRunner.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/ModerationClient/Services/TestRunner.cs b/ModerationClient/Services/TestRunner.cs new file mode 100644 index 0000000..dbacf99 --- /dev/null +++ b/ModerationClient/Services/TestRunner.cs @@ -0,0 +1,36 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Hosting; + +namespace ModerationClient.Services; + +public class TestRunner(CommandLineConfiguration.TestConfig testConfig, MatrixAuthenticationService mas) : IHostedService { + public async Task StartAsync(CancellationToken cancellationToken) { + Console.WriteLine("TestRunner: Starting test runner"); + mas.PropertyChanged += (_, args) => { + if (args.PropertyName == nameof(MatrixAuthenticationService.IsLoggedIn) && mas.IsLoggedIn) { + Console.WriteLine("TestRunner: Logged in, starting test"); + _ = Run(); + } + }; + } + + public async Task StopAsync(CancellationToken cancellationToken) { + Console.WriteLine("TestRunner: Stopping test runner"); + } + + private async Task Run() { + var hs = mas.Homeserver!; + Console.WriteLine("TestRunner: Running test on homeserver " + hs); + foreach (var mxid in testConfig.Mxids) { + var room = await hs.CreateRoom(new() { + Name = mxid, + Invite = testConfig.Mxids + }); + + await room.SendMessageEventAsync(new("test")); + + } + } +} \ No newline at end of file |