25 lines
899 B
C#
25 lines
899 B
C#
using System.Runtime.CompilerServices;
|
|
using ReactiveUI.Builder;
|
|
|
|
namespace PLib.Tests;
|
|
|
|
/// <summary>
|
|
/// Brings ReactiveUI up before any test touches a view model.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// ReactiveUI 24 refuses to serve <c>WhenAnyValue</c> until it has been initialised, and the
|
|
/// application does that in <c>Program.Main</c> — which a test host never runs. Only the core
|
|
/// services are registered here: platform services are about dispatchers and bindings, and a
|
|
/// view model under test has neither.
|
|
/// </remarks>
|
|
internal static class ReactiveUiBootstrap
|
|
{
|
|
[ModuleInitializer]
|
|
internal static void Initialize() =>
|
|
// BuildApp rather than Build: only the former marks ReactiveUI as initialised, and
|
|
// that flag is exactly what WhenAnyValue checks.
|
|
RxAppBuilder.CreateReactiveUIBuilder()
|
|
.WithCoreServices()
|
|
.BuildApp();
|
|
}
|