Ver Fonte

Merge pull request #364 from Reactive-Extensions/RemoveSilverlight

Removing conditional compilation for Silverlight
Bart J.F. De Smet há 8 anos atrás
pai
commit
fef06a9a86
19 ficheiros alterados com 45 adições e 202 exclusões
  1. 0 50
      Rx.NET/Source/tests/Tests.System.Reactive/App.cs
  2. 0 42
      Rx.NET/Source/tests/Tests.System.Reactive/TestBase.cs
  3. 0 3
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/AsyncLockTest.cs
  4. 0 3
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/CurrentThreadSchedulerTest.cs
  5. 0 2
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/DefaultSchedulerTest.cs
  6. 0 10
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/DispatcherSchedulerTest.cs
  7. 0 2
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/EventLoopSchedulerTest.cs
  8. 2 2
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ImmediateSchedulerTest.cs
  9. 0 2
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/NewThreadSchedulerTest.cs
  10. 1 3
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/SynchronizationContextSchedulerTest.cs
  11. 0 2
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ThreadPoolSchedulerTest.cs
  12. 1 1
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/VirtualSchedulerTest.cs
  13. 22 36
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/ObservableBlockingTest.cs
  14. 15 19
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/ObservableConcurrencyTest.cs
  15. 0 8
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/ObservableConversionTests.cs
  16. 0 4
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/QbservableExTest.cs
  17. 0 4
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/QbservableTest.cs
  18. 3 5
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/PrivateTypesTest.cs
  19. 1 4
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/RegressionTest.cs

+ 0 - 50
Rx.NET/Source/tests/Tests.System.Reactive/App.cs

@@ -1,50 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the Apache 2.0 License.
-// See the LICENSE file in the project root for more information. 
-
-#if SILVERLIGHT && !SILVERLIGHTM7
-using System;
-using System.Diagnostics;
-using System.Windows;
-using System.Windows.Browser;
-using Microsoft.Silverlight.Testing;
-
-namespace ReactiveTests
-{
-    public class App : Application
-    {
-        public App()
-        {
-            this.Startup += (o, e) =>
-            {
-                // TODO: Investigate UnitTestSettings configuration of TestService and LogProviders.
-                // var settings = new UnitTestSettings { StartRunImmediately = true };
-                RootVisual = UnitTestSystem.CreateTestPage(/* settings */);
-            };
-
-            this.UnhandledException += (o, e) =>
-            {
-                if (!Debugger.IsAttached)
-                {
-                    e.Handled = true;
-                    Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
-                }
-            };
-        }
-
-        private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
-        {
-            try
-            {
-                string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
-                errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");
-
-                HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
-            }
-            catch (Exception)
-            {
-            }
-        }
-    }
-}
-#endif

+ 0 - 42
Rx.NET/Source/tests/Tests.System.Reactive/TestBase.cs

@@ -3,51 +3,10 @@
 // See the LICENSE file in the project root for more information. 
 
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 using System.Threading;
 
 namespace ReactiveTests
 {
-#if SILVERLIGHT && !SILVERLIGHTM7
-    public class TestBase : Microsoft.Silverlight.Testing.SilverlightTest
-    {
-        public void RunAsync(Action<Waiter> a)
-        {
-            EnqueueCallback(() =>
-            {
-                var w = new Waiter(TestComplete);
-                a(w);
-                w.Wait();
-            });
-        }
-
-        public void CompleteAsync()
-        {
-            EnqueueTestComplete();
-        }
-    }
-
-    public class Waiter
-    {
-        private Action _complete;
-
-        public Waiter(Action complete)
-        {
-            _complete = complete;
-        }
-
-        public void Set()
-        {
-            _complete();
-        }
-
-        public void Wait()
-        {
-        }
-    }
-#else
     public class TestBase
     {
         public void RunAsync(Action<Waiter> a)
@@ -77,5 +36,4 @@ namespace ReactiveTests
     public class AsynchronousAttribute : Attribute
     {
     }
-#endif
 }

+ 0 - 3
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/AsyncLockTest.cs

@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-#if !SILVERLIGHT // MethodAccessException
 using System;
-using System.Threading.Tasks;
 using System.Reactive.Concurrency;
 using System.Reflection;
 using Xunit;
@@ -133,4 +131,3 @@ namespace ReactiveTests.Tests
         }
     }
 }
-#endif

+ 0 - 3
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/CurrentThreadSchedulerTest.cs

@@ -81,8 +81,6 @@ namespace ReactiveTests.Tests
             Assert.True(ran);
         }
 
-#if !SILVERLIGHT
-
         [Fact(Skip ="")]
         public void CurrentThread_ScheduleActionDue()
         {
@@ -114,7 +112,6 @@ namespace ReactiveTests.Tests
             Assert.True(ran, "ran");
             Assert.True(sw.ElapsedMilliseconds > 380, "due " + sw.ElapsedMilliseconds);
         }
-#endif
 #endif
         [Fact]
         public void CurrentThread_EnsureTrampoline()

+ 0 - 2
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/DefaultSchedulerTest.cs

@@ -41,7 +41,6 @@ namespace ReactiveTests.Tests
             evt.WaitOne();
         }
 
-#if !SILVERLIGHT
         [Fact]
         public void ScheduleActionDue()
         {
@@ -51,7 +50,6 @@ namespace ReactiveTests.Tests
             nt.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); evt.Set(); });
             evt.WaitOne();
         }
-#endif
 
         [Fact]
         public void ScheduleActionCancel()

+ 0 - 10
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/DispatcherSchedulerTest.cs

@@ -12,10 +12,6 @@ using System.Windows.Threading;
 using Microsoft.Reactive.Testing;
 using Xunit;
 
-#if SILVERLIGHT && !SILVERLIGHTM7
-using Microsoft.Silverlight.Testing;
-#endif
-
 namespace ReactiveTests.Tests
 {
     
@@ -102,18 +98,13 @@ namespace ReactiveTests.Tests
                 var sch = new DispatcherScheduler(disp);
                 sch.Schedule(() =>
                 {
-#if SILVERLIGHT
-                    Assert.Equal(id, Thread.CurrentThread.ManagedThreadId); // Single-threaded test framework
-#else
                     Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId);
-#endif
                     disp.InvokeShutdown();
                     evt.Set();
                 });
             });
         }
 
-#if !USE_SL_DISPATCHER
         [Fact]
         public void ScheduleError()
         {
@@ -258,7 +249,6 @@ namespace ReactiveTests.Tests
             evt.WaitOne();
             disp.InvokeShutdown();
         }
-#endif
     }
 }
 #endif

+ 0 - 2
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/EventLoopSchedulerTest.cs

@@ -226,7 +226,6 @@ namespace ReactiveTests.Tests
             Assert.True(ran);
         }
 
-#if !SILVERLIGHT
         [Fact(Skip ="")]
         public void EventLoop_ScheduleActionDue()
         {
@@ -270,7 +269,6 @@ namespace ReactiveTests.Tests
             Assert.True(ran, "ran");
             Assert.True(sw.ElapsedMilliseconds > 380, "due " + sw.ElapsedMilliseconds);
         }
-#endif
 
 #if !NO_PERF
         [Fact]

+ 2 - 2
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ImmediateSchedulerTest.cs

@@ -144,8 +144,8 @@ namespace ReactiveTests.Tests
             });
         }
 
-#if !SILVERLIGHT && !NO_THREAD
-        [Fact(Skip="Ignored")]        
+#if !NO_THREAD
+        [Fact(Skip="Ignored")]
         public void Immediate_ScheduleActionDue()
         {
             var id = Thread.CurrentThread.ManagedThreadId;

+ 0 - 2
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/NewThreadSchedulerTest.cs

@@ -44,7 +44,6 @@ namespace ReactiveTests.Tests
             evt.WaitOne();
         }
 
-#if !SILVERLIGHT
         [Fact(Skip = "")]
         public void NewThread_ScheduleActionDue()
         {
@@ -58,7 +57,6 @@ namespace ReactiveTests.Tests
             Assert.True(sw.ElapsedMilliseconds > 180, "due " + sw.ElapsedMilliseconds);
         }
 #endif
-#endif
 
 #if !NO_PERF
         [Fact]

+ 1 - 3
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/SynchronizationContextSchedulerTest.cs

@@ -97,8 +97,7 @@ namespace ReactiveTests.Tests
             Assert.True(ms.Count == 1);
         }
 
-#if !SILVERLIGHT
-        [Fact]        
+        [Fact]
         public void SynchronizationContext_ScheduleActionDue()
         {
             var ms = new MySync();
@@ -112,7 +111,6 @@ namespace ReactiveTests.Tests
             Assert.True(sw.ElapsedMilliseconds > 180, "due " + sw.ElapsedMilliseconds);
             Assert.True(ms.Count == 1);
         }
-#endif
 
         class MySync : SynchronizationContext
         {

+ 0 - 2
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ThreadPoolSchedulerTest.cs

@@ -97,7 +97,6 @@ namespace ReactiveTests.Tests
             cts.Cancel();
         }
 
-#if !SILVERLIGHT
         [Fact]
         public void ScheduleActionDueRelative()
         {
@@ -127,7 +126,6 @@ namespace ReactiveTests.Tests
             nt.Schedule(DateTimeOffset.UtcNow + TimeSpan.FromSeconds(0.2), () => { Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); evt.Set(); });
             evt.WaitOne();
         }
-#endif
 
         [Fact]
         public void ScheduleActionCancel()

+ 1 - 1
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/VirtualSchedulerTest.cs

@@ -112,7 +112,7 @@ namespace ReactiveTests.Tests
             ReactiveAssert.Throws<ArgumentNullException>(() => new HistoricalScheduler().ScheduleRelative(42, TimeSpan.FromSeconds(1), default(Func<IScheduler, int, IDisposable>)));
         }
 
-#if !SILVERLIGHT && !NO_THREAD
+#if !NO_THREAD
         [Fact(Skip = "Ignored")]
         public void Virtual_ScheduleActionDue()
         {

+ 22 - 36
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/ObservableBlockingTest.cs

@@ -20,7 +20,7 @@ using System.Threading.Tasks;
 
 namespace ReactiveTests.Tests
 {
-    
+
     public partial class ObservableBlockingTest : ReactiveTest
     {
         #region Chunkify
@@ -657,9 +657,9 @@ namespace ReactiveTests.Tests
             }
         }
 
-#endregion
+        #endregion
 
-#region + ForEach +
+        #region + ForEach +
 
         [Fact]
         public void ForEach_ArgumentChecking()
@@ -765,9 +765,9 @@ namespace ReactiveTests.Tests
             ReactiveAssert.Throws(ex, () => xs.ForEach((x, i) => { throw ex; }));
         }
 
-#endregion
+        #endregion
 
-#region + GetEnumerator +
+        #region + GetEnumerator +
 
         [Fact]
         public void GetEnumerator_ArgumentChecking()
@@ -916,23 +916,9 @@ namespace ReactiveTests.Tests
             );
         }
 
-#if DESKTOPCLR20 || SILVERLIGHTM7
-        class Tuple<T1, T2>
-        {
-            public Tuple(T1 item1, T2 item2)
-            {
-                Item1 = item1;
-                Item2 = item2;
-            }
-
-            public T1 Item1 { get; private set; }
-            public T2 Item2 { get; private set; }
-        }
-#endif
-
-#endregion
+        #endregion
 
-#region Last
+        #region Last
 
         [Fact]
         public void Last_ArgumentChecking()
@@ -985,9 +971,9 @@ namespace ReactiveTests.Tests
             Assert.Equal(50, Observable.Range(value, 10).Last(i => i % 2 == 0));
         }
 
-#endregion
+        #endregion
 
-#region LastOrDefault
+        #region LastOrDefault
 
         [Fact]
         public void LastOrDefault_ArgumentChecking()
@@ -1040,9 +1026,9 @@ namespace ReactiveTests.Tests
             Assert.Equal(50, Observable.Range(value, 10).LastOrDefault(i => i % 2 == 0));
         }
 
-#endregion
+        #endregion
 
-#region + Latest +
+        #region + Latest +
 
         [Fact]
         public void Latest_ArgumentChecking()
@@ -1201,9 +1187,9 @@ namespace ReactiveTests.Tests
             ReactiveAssert.Throws(ex, () => res.MoveNext());
         }
 
-#endregion
+        #endregion
 
-#region + MostRecent +
+        #region + MostRecent +
 
         [Fact]
         public void MostRecent_ArgumentChecking()
@@ -1387,9 +1373,9 @@ namespace ReactiveTests.Tests
             ReactiveAssert.Throws(ex, () => res.MoveNext());
         }
 
-#endregion
+        #endregion
 
-#region + Next +
+        #region + Next +
 
         [Fact]
         public void Next_ArgumentChecking()
@@ -1541,9 +1527,9 @@ namespace ReactiveTests.Tests
             ReactiveAssert.Throws(ex, () => res.MoveNext());
         }
 #endif
-#endregion
+        #endregion
 
-#region Single
+        #region Single
 
         [Fact]
         public void Single_ArgumentChecking()
@@ -1603,9 +1589,9 @@ namespace ReactiveTests.Tests
             Assert.Equal(45, Observable.Range(value, 10).Single(i => i == 45));
         }
 
-#endregion
+        #endregion
 
-#region SingleOrDefault
+        #region SingleOrDefault
 
         [Fact]
         public void SingleOrDefault_ArgumentChecking()
@@ -1672,9 +1658,9 @@ namespace ReactiveTests.Tests
             Assert.Equal(0, Observable.Range(value, 10).SingleOrDefault(i => i > 100));
         }
 
-#endregion
+        #endregion
 
-#region Wait
+        #region Wait
 
         [Fact]
         public void Wait_ArgumentChecking()
@@ -1719,6 +1705,6 @@ namespace ReactiveTests.Tests
             Assert.Equal(n, res);
         }
 #endif
-#endregion
+        #endregion
     }
 }

+ 15 - 19
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/ObservableConcurrencyTest.cs

@@ -22,16 +22,12 @@ using ReactiveTests.Dummies;
 using System.Windows.Forms;
 #endif
 
-#if SILVERLIGHT && !SILVERLIGHTM7
-using Microsoft.Silverlight.Testing;
-#endif
-
 namespace ReactiveTests.Tests
 {
-    
+
     public partial class ObservableConcurrencyTest : TestBase
     {
-#region + ObserveOn +
+        #region + ObserveOn +
 
         [Fact]
         public void ObserveOn_ArgumentChecking()
@@ -226,9 +222,9 @@ namespace ReactiveTests.Tests
             });
         }
 #endif
-#endregion
+        #endregion
 
-#region SubscribeOn
+        #region SubscribeOn
 
         [Fact]
         public void SubscribeOn_ArgumentChecking()
@@ -426,9 +422,9 @@ namespace ReactiveTests.Tests
             });
         }
 #endif
-#endregion
+        #endregion
 
-#region + Synchronize +
+        #region + Synchronize +
 
         [Fact]
         public void Synchronize_ArgumentChecking()
@@ -539,13 +535,13 @@ namespace ReactiveTests.Tests
             Assert.Equal(Enumerable.Range(0, 200).Sum(), sum);
         }
 #endif
-#endregion
+        #endregion
     }
 
-    
+
     public class ObservableConcurrencyReactiveTest : ReactiveTest
     {
-#region + ObserveOn +
+        #region + ObserveOn +
 
         [Fact]
         public void ObserveOn_Scheduler_ArgumentChecking()
@@ -560,7 +556,7 @@ namespace ReactiveTests.Tests
             var scheduler = new TestScheduler();
 
             var xs = scheduler.CreateHotObservable(
-                OnNext( 90, 1),
+                OnNext(90, 1),
                 OnNext(120, 2),
                 OnNext(230, 3),
                 OnNext(240, 4),
@@ -969,9 +965,9 @@ namespace ReactiveTests.Tests
         }
 #endif
 
-#endregion
+        #endregion
 
-#region SubscribeOn
+        #region SubscribeOn
 
         [Fact]
         public void SubscribeOn_Scheduler_ArgumentChecking()
@@ -1105,9 +1101,9 @@ namespace ReactiveTests.Tests
         }
 #endif
 
-#endregion
+        #endregion
 
-#region |> Helpers <|
+        #region |> Helpers <|
 
 #if !NO_SYNCCTX
         class MyCtx : SynchronizationContext
@@ -1126,6 +1122,6 @@ namespace ReactiveTests.Tests
         }
 #endif
 
-#endregion
+        #endregion
     }
 }

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

@@ -125,7 +125,6 @@ namespace ReactiveTests.Tests
             );
         }
 
-#if !SILVERLIGHTM7
         [Fact]
         public void SubscribeToEnumerable_DefaultScheduler()
         {
@@ -151,7 +150,6 @@ namespace ReactiveTests.Tests
                 results1.AssertEqual(results2);
             }
         }
-#endif
 
         #endregion
 
@@ -485,10 +483,8 @@ namespace ReactiveTests.Tests
             src.OnCompleted();
             Assert.Equal(2, num);
 
-#if !SILVERLIGHT // FieldAccessException
             var tbl = GetSubscriptionTable(evt);
             Assert.True(tbl.Count == 0);
-#endif
         }
 
         [Fact]
@@ -514,10 +510,8 @@ namespace ReactiveTests.Tests
 
             ReactiveAssert.Throws(ex, () => src.OnError(ex));
 
-#if !SILVERLIGHT // FieldAccessException
             var tbl = GetSubscriptionTable(evt);
             Assert.True(tbl.Count == 0);
-#endif
         }
 
         [Fact]
@@ -535,10 +529,8 @@ namespace ReactiveTests.Tests
 
                 Assert.Equal(0, num);
 
-#if !SILVERLIGHT // FieldAccessException
                 var tbl = GetSubscriptionTable(evt);
                 Assert.True(tbl.Count == 0);
-#endif
             }
         }
 

+ 0 - 4
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/QbservableExTest.cs

@@ -2,8 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-#if !SILVERLIGHTM7
-
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -71,5 +69,3 @@ namespace ReactiveTests.Tests
         }
     }
 }
-
-#endif

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

@@ -3,8 +3,6 @@
 // See the LICENSE file in the project root for more information. 
 #define DEBUG // so that the Debug.WriteLines aren't compiled out
 
-#if !SILVERLIGHTM7
-
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -2150,5 +2148,3 @@ namespace ReactiveTests.Tests
         }
     }
 }
-
-#endif

+ 3 - 5
Rx.NET/Source/tests/Tests.System.Reactive/Tests/PrivateTypesTest.cs

@@ -2,17 +2,16 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-#if !SILVERLIGHT // Reflection security restrictions
+using Microsoft.Reactive.Testing;
 using System;
 using System.Linq;
-using Xunit;
-using Microsoft.Reactive.Testing;
 using System.Reactive.Linq;
 using System.Reflection;
+using Xunit;
 
 namespace ReactiveTests.Tests
 {
-    
+
     public partial class PrivateTypesTest : ReactiveTest
     {
         [Fact]
@@ -239,4 +238,3 @@ namespace ReactiveTests.Tests
         }
     }
 }
-#endif

+ 1 - 4
Rx.NET/Source/tests/Tests.System.Reactive/Tests/RegressionTest.cs

@@ -138,7 +138,6 @@ namespace ReactiveTests.Tests
             Assert.True(flag);
         }
 
-#if !SILVERLIGHTM7
 #if !NO_THREAD
         static IEnumerable<int> Bug_1333_Enumerable(AsyncSubject<IDisposable> s, Semaphore sema)
         {
@@ -148,8 +147,7 @@ namespace ReactiveTests.Tests
             t.Join();
             yield return 1;
         }
-#endif
-#if !NO_THREAD
+
         [Fact]
         //[Timeout(1000)]
         public void Bug_1333()
@@ -161,7 +159,6 @@ namespace ReactiveTests.Tests
             d.OnCompleted();
             sema.WaitOne();
         }
-#endif
 #endif
 
         [Fact]