From d0ff2eb66e3eb248f536e2281d7dbf3ca5fd6d54 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 18 Oct 2018 16:37:16 +0200 Subject: [PATCH] Don't register MainThreadScheduler when in unit tests. Unit tests require a CurrentThreadScheduler to be used, this was overriding that, causing intermittent test failures. --- src/ReactiveUI.Wpf/Registrations.cs | 4 +++- src/ReactiveUI/Platforms/net461/PlatformRegistrations.cs | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ReactiveUI.Wpf/Registrations.cs b/src/ReactiveUI.Wpf/Registrations.cs index 2867b3522a..5634de399e 100644 --- a/src/ReactiveUI.Wpf/Registrations.cs +++ b/src/ReactiveUI.Wpf/Registrations.cs @@ -20,7 +20,9 @@ public void Register(Action, Type> registerFunction) RxApp.TaskpoolScheduler = TaskPoolScheduler.Default; - RxApp.MainThreadScheduler = new WaitForDispatcherScheduler(() => DispatcherScheduler.Current); + if (!Splat.ModeDetector.InUnitTestRunner()) { + RxApp.MainThreadScheduler = new WaitForDispatcherScheduler(() => DispatcherScheduler.Current); + } } } } diff --git a/src/ReactiveUI/Platforms/net461/PlatformRegistrations.cs b/src/ReactiveUI/Platforms/net461/PlatformRegistrations.cs index 7e840ea570..675e4c0e84 100644 --- a/src/ReactiveUI/Platforms/net461/PlatformRegistrations.cs +++ b/src/ReactiveUI/Platforms/net461/PlatformRegistrations.cs @@ -13,7 +13,10 @@ public void Register(Action, Type> registerFunction) { registerFunction(() => new ComponentModelTypeConverter(), typeof(IBindingTypeConverter)); RxApp.TaskpoolScheduler = TaskPoolScheduler.Default; - RxApp.MainThreadScheduler = DefaultScheduler.Instance; + + if (!Splat.ModeDetector.InUnitTestRunner()) { + RxApp.MainThreadScheduler = DefaultScheduler.Instance; + } } } }