Skip to content

Commit

Permalink
Allow method name to be seen for testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusfriedman committed Nov 21, 2023
1 parent 1644ab4 commit d070f6e
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions UnitTests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ public static async Task Main(string[] args)

RunTest(RtspClientTests);

await RunTestAsync(TestServerAsync);
RunTest(async () =>
{
await RunTestAsync(TestServerAsync);
});
}

#region Unit Tests
Expand Down Expand Up @@ -2147,6 +2150,8 @@ static void TestRtspClient(string location, System.Net.NetworkCredential cred =
static async Task TestServerAsync()
{

Console.WriteLine(nameof(TestServerAsync));

System.Runtime.GCLatencyMode oldMode = System.Runtime.GCSettings.LatencyMode;

try
Expand Down Expand Up @@ -4621,19 +4626,14 @@ static void TraceMessage(string message,

static void RunTest(Action test, int count = 1, bool waitForGoAhead = true)
{
System.Console.Clear();
Console.WriteLine("About to run test: " + test.Method.Name);
Console.WriteLine("Press Q to skip or any other key to continue.");
RunTestAsync(() => { test(); return Task.CompletedTask; }, count, waitForGoAhead).GetAwaiter().GetResult();
}

static async Task RunTestAsync(Func<Task> test, int count = 1, bool waitForGoAhead = true)
{
System.Console.Clear();
ConsoleColor pForeGround = Console.ForegroundColor,
pBackGound = Console.BackgroundColor;
Console.BackgroundColor = ConsoleColor.Blue;
Console.WriteLine("About to run test: " + test.Method.Name);
Console.WriteLine("Press Q to skip or any other key to continue.");
Console.BackgroundColor = ConsoleColor.Black;

//If the debugger is attached get a ConsoleKey, the key is Q return.
if (waitForGoAhead && /*System.Diagnostics.Debugger.IsAttached && */ Console.ReadKey(true).Key == ConsoleKey.Q) return;
else
Expand All @@ -4652,12 +4652,12 @@ static async Task RunTestAsync(Func<Task> test, int count = 1, bool waitForGoAhe
//Decrement remaining
--remaining;

TraceMessage("Beginning Test '" + testIndex + "'", test.Method.Name);
TraceMessage("Beginning Test '" + testIndex + "'");

//Run the test
await test();

TraceMessage("Completed Test'" + testIndex + "'", test.Method.Name);
TraceMessage("Completed Test'" + testIndex + "'");

//Increment the success counter
++successes;
Expand Down Expand Up @@ -4723,11 +4723,6 @@ static async Task RunTestAsync(Func<Task> test, int count = 1, bool waitForGoAhe
}

}

Console.BackgroundColor = pBackGound;

Console.ForegroundColor = pForeGround;

}

internal static void TryPrintClientPacket(object sender, bool incomingFlag, Media.Common.IPacket packet, Common.IDisposed context = null, bool writePayload = false)
Expand Down

0 comments on commit d070f6e

Please sign in to comment.