Added a NUnit test project for the whole solution

This commit is contained in:
Thorsten Sommer committed 2026-09-11 16:37:09 +02:00
1 parent d21e09dd1e
commit de775048f0
6 files changed
+135 -1

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
using Microsoft.Extensions.Logging.Abstractions;
//
// Deliberately without a namespace: NUnit then applies this fixture to the whole assembly, so every
// test -- the ones written today and the ones written later in some other folder -- starts with the
// static state below already in place. A second setup fixture would only ever be needed for state
// that must not leak between areas.
//
namespace AIStudio.Tests;
[SetUpFixture]
public sealed class TestHost
{
[OneTimeSetUp]
public void PrepareStaticApplicationState()
{
//
// A number of types in the app hold a static logger field that is initialized from
// Program.LOGGER_FACTORY, among them Settings.Provider. The app assigns that factory while
// Kestrel comes up; in a test process nobody does, so it stays null and the first touch of
// such a type dies inside its type initializer -- before a single assertion runs. A factory
// that writes nowhere is all it takes to get past that.
//
Program.LOGGER_FACTORY = NullLoggerFactory.Instance;
}
}