Browse Source

Ensure Dispatcher available in test that presume it

It looks like a few tests that fetched DispatcherScheduler.Current used to rely on the Dispatcher already having been created. Up until recently, that was true by random chance. But recent changes, which presumably have affected the order of test execution, mean that's no longer true.

These tests should always have ensured a dispatcher was available before starting to run, and now they do.
Ian Griffiths 1 year ago
parent
commit
af836b7b28

+ 4 - 0
Rx.NET/Source/CodeCoverage.runsettings

@@ -1,6 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <!-- File name extension must be .runsettings -->
 <!-- File name extension must be .runsettings -->
 <RunSettings>
 <RunSettings>
+  <RunConfiguration>
+    <ExecutionThreadApartmentState>STA</ExecutionThreadApartmentState>
+  </RunConfiguration>
+	
   <DataCollectionRunSettings>
   <DataCollectionRunSettings>
     <DataCollectors>
     <DataCollectors>
        <DataCollector friendlyName="XPlat code coverage">
        <DataCollector friendlyName="XPlat code coverage">

+ 8 - 0
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/SchedulerTest.cs

@@ -34,6 +34,14 @@ namespace ReactiveTests.Tests
     [TestClass]
     [TestClass]
     public class SchedulerTest : ReactiveTest
     public class SchedulerTest : ReactiveTest
     {
     {
+#if HAS_DISPATCHER
+        [TestInitialize]
+        public void EnsureDispatcherAvailable()
+        {
+            _ = new System.Windows.DependencyObject();
+        }
+#endif
+
         #region IScheduler
         #region IScheduler
 
 
         [TestMethod]
         [TestMethod]

+ 8 - 0
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/QbservableTest.cs

@@ -39,6 +39,14 @@ namespace ReactiveTests.Tests
         private readonly IQbservable<int> _qbMy = new MyQbservable<int>();
         private readonly IQbservable<int> _qbMy = new MyQbservable<int>();
         private readonly IQbservableProvider _qbp = new MyQbservableProvider();
         private readonly IQbservableProvider _qbp = new MyQbservableProvider();
 
 
+#if HAS_DISPATCHER
+        [TestInitialize]
+        public void EnsureDispatcherAvailable()
+        {
+            _ = new System.Windows.DependencyObject();
+        }
+#endif
+
         [TestMethod]
         [TestMethod]
         public void LocalQueryMethodImplementationTypeAttribute()
         public void LocalQueryMethodImplementationTypeAttribute()
         {
         {