Remove Initialize calls and add AddStatement tests

This commit is contained in:
Stone_Red
2026-03-04 19:41:19 +01:00
parent 8e0abf155a
commit b2fdd9c841
8 changed files with 250 additions and 16 deletions
+22 -1
View File
@@ -67,10 +67,31 @@ internal static class YesNtAssert
StringAssert.Matches(value, new Regex(pattern));
}
public static void IsLastLineEqualWithSetup(List<string> lines, string expected, Action<YesNtInterpreter> setup, int timeout = 1000)
{
(DebugEventArgs? debugEventArgs, _) = ExecuteAndCapture(lines, timeout, setup);
Assert.AreEqual(expected, debugEventArgs?.CurrentLine);
}
public static void ContainsDebugOutputWithSetup(List<string> lines, string expectedFragment, Action<YesNtInterpreter> setup, int timeout = 1000)
{
(_, string debugOutput) = ExecuteAndCapture(lines, timeout, setup);
StringAssert.Contains(debugOutput, expectedFragment);
}
public static string? GetLastLineWithSetup(List<string> lines, Action<YesNtInterpreter> setup, int timeout = 1000)
{
(DebugEventArgs? debugEventArgs, _) = ExecuteAndCapture(lines, timeout, setup);
return debugEventArgs?.CurrentLine;
}
private static (DebugEventArgs? LastDebugEvent, string DebugOutput) ExecuteAndCapture(List<string> lines, int timeout)
=> ExecuteAndCapture(lines, timeout, setup: null);
private static (DebugEventArgs? LastDebugEvent, string DebugOutput) ExecuteAndCapture(List<string> lines, int timeout, Action<YesNtInterpreter>? setup)
{
YesNtInterpreter yesNtInterpreter = new YesNtInterpreter();
yesNtInterpreter.Initialize();
setup?.Invoke(yesNtInterpreter);
AutoResetEvent onDone = new AutoResetEvent(false);
DebugEventArgs? debugEventArgs = null;