LibHac/tests/LibHac.Tests/LibHacTestFramework.cs

46 lines
1.2 KiB
C#
Raw Normal View History

using System.Diagnostics;
using System.Linq;
using LibHac.Diag;
using LibHac.Tests;
using Xunit.Abstractions;
using Xunit.Sdk;
[assembly: Xunit.TestFramework("LibHac.Tests." + nameof(LibHacTestFramework), "LibHac.Tests")]
2021-11-14 20:08:57 +01:00
namespace LibHac.Tests;
public class LibHacTestFramework : XunitTestFramework
{
2021-11-14 20:08:57 +01:00
public LibHacTestFramework(IMessageSink messageSink)
: base(messageSink)
{
2021-11-14 20:08:57 +01:00
SetDebugHandler();
SetResultNames();
}
2021-11-14 20:08:57 +01:00
// Todo: Catch assertions in PathToolTestGenerator.cpp
private static readonly string[] SkipAbortFunctions = { "Normalize" };
2021-11-14 20:08:57 +01:00
private static void SetDebugHandler()
{
AssertionFailureHandler handler = (in AssertionInfo info) =>
{
2021-11-14 20:08:57 +01:00
if (SkipAbortFunctions.Contains(info.FunctionName))
{
2021-11-14 20:08:57 +01:00
return AssertionFailureOperation.Continue;
}
2021-11-14 20:08:57 +01:00
return AssertionFailureOperation.Abort;
};
2021-11-14 20:08:57 +01:00
Assert.SetAssertionFailureHandler(handler);
Trace.Listeners.Clear();
Trace.Listeners.Add(new DebugAssertHandler());
}
2021-11-14 20:08:57 +01:00
private static void SetResultNames()
{
Result.SetNameResolver(new ResultNameResolver());
}
}