Repository navigation
Expand file tree
/
Copy pathTest_IMaaAgentServer.cs
More file actions
47 lines (41 loc) · 1.56 KB
/
Copy pathTest_IMaaAgentServer.cs
File metadata and controls
47 lines (41 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
namespace MaaFramework.Binding.UnitTests;
internal static class Test_IMaaAgentServer
{
public static int Main()
{
var commandLineArgs = Environment.GetCommandLineArgs();
if (commandLineArgs.Length < 4)
{
Console.WriteLine("Call AgentMain.cs instead of this file.");
return 1;
}
var socketId = commandLineArgs[^1];
var userPath = commandLineArgs[^2];
var dllPath = commandLineArgs[^3];
Test(socketId, userPath, dllPath);
return 0;
}
public static void Test(string id, string userPath, string dllPath)
{
_ = MaaAgentServer.Current // test double call
.WithIdentifier(id).WithIdentifier(id) // before .StartUp()
.WithNativeLibrary(dllPath).WithNativeLibrary(dllPath); // before other methods include events
MaaAgentServer.Current.Callback += OnCallback;
_ = MaaAgentServer.Current
.SetStdoutLevel(LoggingLevel.All)
.SetLogDirectory(Path.Combine(userPath, "debug", "server-" + id))
.Register(Custom.Recognition) // cat not double call from here
.Register(Custom.Action)
.StartUp()
.Join().Join() // test double call
.ShutDown().ShutDown();
}
internal static bool CallbackInvoked { get; set; }
internal static void OnCallback(object? sender, MaaCallbackEventArgs e)
{
CallbackInvoked = true;
Assert.IsNotNull(sender);
Assert.IsNotNull(e);
Assert.IsFalse(string.IsNullOrWhiteSpace(e.Message));
}
}