Oren Novotny 9 anni fa
parent
commit
2832275689

+ 9 - 7
Rx.NET/Source/Tests.System.Reactive/Stress/Linq/Delay.cs

@@ -1,9 +1,11 @@
 // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
-
+#define DEBUG // For debug.writeline
 using System;
+using System.Diagnostics;
 using System.Reactive.Concurrency;
 using System.Reactive.Linq;
 
+
 namespace ReactiveTests.Stress.Linq
 {
     public class Delay
@@ -17,7 +19,7 @@ namespace ReactiveTests.Stress.Linq
             {
                 foreach (var N in new[] { 1, 10, 100, 1000, 10000, 100000 })
                 {
-                    Console.WriteLine("N = {0}", N);
+                    Debug.WriteLine("N = {0}", N);
                     foreach (var d in new[] { 1, 10, 20, 50, 100, 200, 250, 500 })
                     {
                         try
@@ -27,13 +29,13 @@ namespace ReactiveTests.Stress.Linq
                         }
                         catch (Exception)
                         {
-                            Console.Write(".");
+                            Debug.Write(".");
                             continue;
                         }
 
                         throw new InvalidOperationException("Didn't throw!");
                     }
-                    Console.WriteLine();
+                    Debug.WriteLine("");
                 }
             }
         }
@@ -47,16 +49,16 @@ namespace ReactiveTests.Stress.Linq
             {
                 foreach (var N in new[] { 1, 10, 100, 1000, 10000, 100000 })
                 {
-                    Console.WriteLine("N = {0}", N);
+                    Debug.WriteLine("N = {0}", N);
                     foreach (var d in new[] { 1, 10, 20, 50, 100, 200, 250, 500 })
                     {
                         var n = Observable.Range(0, N, NewThreadScheduler.Default).Delay(TimeSpan.FromMilliseconds(d), NewThreadScheduler.Default).Count().Wait();
                         if (n != N)
                             throw new InvalidOperationException("Lost OnNext message!");
 
-                        Console.Write(".");
+                        Debug.Write(".");
                     }
-                    Console.WriteLine();
+                    Debug.WriteLine("");
                 }
             }
         }

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

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

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

@@ -10,7 +10,7 @@ using Xunit;
 
 namespace ReactiveTests.Tests
 {
-    
+#if !NO_THREAD
     public class NewThreadSchedulerTest
     {
         [Fact]
@@ -117,4 +117,5 @@ namespace ReactiveTests.Tests
         }
 #endif
     }
+#endif
 }

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

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

+ 22 - 22
Rx.NET/Source/Tests.System.Reactive/Tests/Disposables/DisposableTests.cs

@@ -22,10 +22,10 @@ namespace ReactiveTests.Tests
             Assert.NotNull(d);
         }
 
-        [Fact, ExpectedException(typeof(ArgumentNullException))]
+        [Fact]
         public void AnonymousDisposable_CreateNull()
         {
-            Disposable.Create(null);
+            Assert.Throws(typeof(ArgumentNullException), () => Disposable.Create(null));            
         }
 
         [Fact]
@@ -147,22 +147,22 @@ namespace ReactiveTests.Tests
             Assert.False(new CompositeDisposable().IsReadOnly);
         }
 
-        [Fact, ExpectedException(typeof(ArgumentNullException))]
+        [Fact]
         public void CompositeDisposable_CopyTo_Null()
         {
-            new CompositeDisposable().CopyTo(null, 0);
+            ReactiveAssert.Throws<ArgumentNullException>(() => new CompositeDisposable().CopyTo(null, 0));
         }
 
-        [Fact, ExpectedException(typeof(ArgumentOutOfRangeException))]
+        [Fact]
         public void CompositeDisposable_CopyTo_Negative()
         {
-            new CompositeDisposable().CopyTo(new IDisposable[2], -1);
+            ReactiveAssert.Throws<ArgumentOutOfRangeException>(() => new CompositeDisposable().CopyTo(new IDisposable[2], -1));
         }
 
-        [Fact, ExpectedException(typeof(ArgumentOutOfRangeException))]
+        [Fact]
         public void CompositeDisposable_CopyTo_BeyondEnd()
         {
-            new CompositeDisposable().CopyTo(new IDisposable[2], 2);
+            ReactiveAssert.Throws<ArgumentOutOfRangeException>(() => new CompositeDisposable().CopyTo(new IDisposable[2], 2));
         }
 
         [Fact]
@@ -224,24 +224,24 @@ namespace ReactiveTests.Tests
             Assert.True(g.Contains(d2));
         }
 
-        [Fact, ExpectedException(typeof(ArgumentException))]
+        [Fact]
         public void CompositeDisposable_AddNull_via_params_ctor()
         {
             IDisposable d1 = null;
-            new CompositeDisposable(d1);
+            ReactiveAssert.Throws<ArgumentException>(() => new CompositeDisposable(d1));
         }
 
-        [Fact, ExpectedException(typeof(ArgumentException))]
+        [Fact]
         public void CompositeDisposable_AddNull_via_IEnum_ctor()
         {
             IEnumerable<IDisposable> values = new IDisposable[] { null };
-            new CompositeDisposable(values);
+            ReactiveAssert.Throws<ArgumentException>(() => new CompositeDisposable(values));
         }
 
-        [Fact, ExpectedException(typeof(ArgumentNullException))]
+        [Fact]
         public void CompositeDisposable_AddNull()
         {
-            new CompositeDisposable().Add(null);
+            ReactiveAssert.Throws<ArgumentNullException>(() => new CompositeDisposable().Add(null));
         }
 
         [Fact]
@@ -372,10 +372,10 @@ namespace ReactiveTests.Tests
             Assert.True(z.SequenceEqual(Enumerable.Range(0, N).Where(i => !(i % 2 == 0 || i % 3 == 0 || i % 5 == 0))));
         }
 
-        [Fact, ExpectedException(typeof(ArgumentNullException))]
+        [Fact]
         public void CompositeDisposable_RemoveNull()
         {
-            new CompositeDisposable().Remove(null);
+            ReactiveAssert.Throws<ArgumentNullException>(() => new CompositeDisposable().Remove(null));
         }
 
 #if DESKTOPCLR40 || DESKTOPCLR45 || DESKTOPCLR46
@@ -410,16 +410,16 @@ namespace ReactiveTests.Tests
             Assert.True(c.Token.IsCancellationRequested);
         }
 #endif
-        [Fact, ExpectedException(typeof(ArgumentNullException))]
+        [Fact]
         public void ContextDisposable_CreateNullContext()
         {
-            new ContextDisposable(null, Disposable.Empty);
+            ReactiveAssert.Throws<ArgumentNullException>(() => new ContextDisposable(null, Disposable.Empty));
         }
 
-        [Fact, ExpectedException(typeof(ArgumentNullException))]
+        [Fact]
         public void ContextDisposable_CreateNullDisposable()
         {
-            new ContextDisposable(new SynchronizationContext(), null);
+            ReactiveAssert.Throws<ArgumentNullException>(() => new ContextDisposable(new SynchronizationContext(), null));
         }
 
         [Fact]
@@ -512,10 +512,10 @@ namespace ReactiveTests.Tests
             //Assert.Null(m.Disposable); // BREAKING CHANGE v2 > v1.x - Undefined behavior after disposal.
         }
 
-        [Fact, ExpectedException(typeof(ArgumentNullException))]
+        [Fact]
         public void RefCountDisposable_Ctor_Null()
         {
-            new RefCountDisposable(null);
+            ReactiveAssert.Throws<ArgumentNullException>(() => new RefCountDisposable(null));
         }
 
         [Fact]

+ 13 - 9
Rx.NET/Source/Tests.System.Reactive/Tests/Linq/ObservableAggregateTest.cs

@@ -2356,6 +2356,7 @@ namespace ReactiveTests.Tests
         }
 
 #if !NO_PERF
+#if !NO_THREAD
         [Fact]
         public void Average_InjectOverflow_Int32()
         {
@@ -2455,7 +2456,8 @@ namespace ReactiveTests.Tests
 
             ReactiveAssert.Throws<OverflowException>(() => res.ForEach(_ => { }));
         }
-
+#endif
+#if !CRIPPLED_REFLECTION
         class OverflowInjection<T> : IObservable<T>
         {
             private readonly IObservable<T> _source;
@@ -2475,6 +2477,7 @@ namespace ReactiveTests.Tests
                 return _source.Subscribe(observer);
             }
         }
+#endif
 #endif
 
         [Fact]
@@ -3148,7 +3151,7 @@ namespace ReactiveTests.Tests
             );
         }
 
-#if !NO_PERF
+#if !NO_PERF && !NO_THREAD
         [Fact]
         public void Count_InjectOverflow()
         {
@@ -3443,7 +3446,8 @@ namespace ReactiveTests.Tests
             );
         }
 
-#if !NO_PERF
+#if !NO_PERF && !NO_THREAD && !CRIPPLED_REFLECTION
+
         [Fact]
         public void Count_Predicate_InjectOverflow()
         {
@@ -4811,7 +4815,7 @@ namespace ReactiveTests.Tests
             );
         }
 
-#if !NO_PERF
+#if !NO_PERF && !NO_THREAD
         [Fact]
         public void LongCount_InjectOverflow()
         {
@@ -5106,7 +5110,7 @@ namespace ReactiveTests.Tests
             );
         }
 
-#if !NO_PERF
+#if !NO_PERF && !NO_THREAD && !CRIPPLED_REFLECTION
         [Fact]
         public void LongCount_Predicate_InjectOverflow()
         {
@@ -7461,7 +7465,7 @@ namespace ReactiveTests.Tests
                 OnCompleted<string>(240)
             );
 
-            var res = scheduler.Start(() => xs.Max(x => new string(x.Reverse().ToArray())));
+            var res = scheduler.Start(() => xs.Max(x => new string(x.ToCharArray().Reverse().ToArray())));
 
             res.Messages.AssertEqual(
                 OnNext(240, "xuq"),
@@ -7485,7 +7489,7 @@ namespace ReactiveTests.Tests
                 OnCompleted<string>(240)
             );
 
-            var res = scheduler.Start(() => xs.Max(x => new string(x.Reverse().ToArray()), new ReverseComparer<string>(Comparer<string>.Default)));
+            var res = scheduler.Start(() => xs.Max(x => new string(x.ToCharArray().Reverse().ToArray()), new ReverseComparer<string>(Comparer<string>.Default)));
 
             res.Messages.AssertEqual(
                 OnNext(240, "oof"),
@@ -10198,7 +10202,7 @@ namespace ReactiveTests.Tests
                 OnCompleted<string>(240)
             );
 
-            var res = scheduler.Start(() => xs.Min(x => new string(x.Reverse().ToArray())));
+            var res = scheduler.Start(() => xs.Min(x => new string(x.ToCharArray().Reverse().ToArray())));
 
             res.Messages.AssertEqual(
                 OnNext(240, "oof"),
@@ -10222,7 +10226,7 @@ namespace ReactiveTests.Tests
                 OnCompleted<string>(240)
             );
 
-            var res = scheduler.Start(() => xs.Min(x => new string(x.Reverse().ToArray()), new ReverseComparer<string>(Comparer<string>.Default)));
+            var res = scheduler.Start(() => xs.Min(x => new string(x.ToCharArray().Reverse().ToArray()), new ReverseComparer<string>(Comparer<string>.Default)));
 
             res.Messages.AssertEqual(
                 OnNext(240, "xuq"),

+ 4 - 1
Rx.NET/Source/Tests.System.Reactive/Tests/Linq/ObservableBlockingTest.cs

@@ -1678,6 +1678,7 @@ namespace ReactiveTests.Tests
             ReactiveAssert.Throws<ArgumentNullException>(() => Observable.Wait(default(IObservable<int>)));
         }
 
+#if !NO_THREAD
         [Fact]
         public void Wait_Return()
         {
@@ -1686,6 +1687,7 @@ namespace ReactiveTests.Tests
             var res = xs.Wait();
             Assert.Equal(x, res);
         }
+#endif
 
         [Fact]
         public void Wait_Empty()
@@ -1703,6 +1705,7 @@ namespace ReactiveTests.Tests
             ReactiveAssert.Throws(ex, () => xs.Wait());
         }
 
+#if !NO_THREAD
         [Fact]
         public void Wait_Range()
         {
@@ -1711,7 +1714,7 @@ namespace ReactiveTests.Tests
             var res = xs.Wait();
             Assert.Equal(n, res);
         }
-
+#endif
 #endregion
     }
 }

+ 3 - 3
Rx.NET/Source/Tests.System.Reactive/Tests/Linq/ObservableImperativeTest.cs

@@ -1790,7 +1790,7 @@ namespace ReactiveTests.Tests
         #endregion
 
         #region General tests for loops
-
+#if HAS_STACKTRACE
         [Fact]
         public void LoopTest1()
         {
@@ -1846,7 +1846,7 @@ namespace ReactiveTests.Tests
             Assert.True(res.SequenceEqual(Enumerable.Repeat(42, 10)));
             Assert.True(std.Distinct().Count() == 1);
         }
-
-        #endregion
+#endif
+#endregion
     }
 }

+ 8 - 2
Rx.NET/Source/Tests.System.Reactive/Tests/Linq/ObservableMultipleTest.cs

@@ -1866,6 +1866,7 @@ namespace ReactiveTests.Tests
             res.Messages.AssertEqual(expected);
         }
 
+#if HAS_STACKTRACE && !NO_THREAD
         [Fact]
         public void Catch_TailRecursive2()
         {
@@ -1877,6 +1878,7 @@ namespace ReactiveTests.Tests
 
             Assert.True(lst.Last() - lst.First() < 10);
         }
+#endif
 
         [Fact]
         public void Catch_TailRecursive3()
@@ -1910,7 +1912,7 @@ namespace ReactiveTests.Tests
         }
 #endif
 
-        #endregion
+#endregion
 
         #region + CombineLatest +
 
@@ -6619,6 +6621,7 @@ namespace ReactiveTests.Tests
             res.Messages.AssertEqual(expected);
         }
 
+#if !NO_THREAD
         [Fact]
         public void Concat_TailRecursive2()
         {
@@ -6631,6 +6634,7 @@ namespace ReactiveTests.Tests
             Assert.True(lst.Last() - lst.First() < 10);
         }
 #endif
+#endif
 
 #if !NO_TPL
         [Fact]
@@ -9251,6 +9255,7 @@ namespace ReactiveTests.Tests
             res.Messages.AssertEqual(expected);
         }
 
+#if HAS_STACKTRACE && !NO_THREAD
         [Fact]
         public void OnErrorResumeNext_TailRecursive2()
         {
@@ -9262,6 +9267,7 @@ namespace ReactiveTests.Tests
 
             Assert.True(lst.Last() - lst.First() < 10);
         }
+#endif
 
         [Fact]
         public void OnErrorResumeNext_TailRecursive3()
@@ -9297,7 +9303,7 @@ namespace ReactiveTests.Tests
         }
 #endif
 
-        #endregion
+#endregion
 
         #region + SkipUntil +
 

+ 6 - 0
Rx.NET/Source/Tests.System.Reactive/Tests/Linq/ObservableTimeTest.cs

@@ -907,6 +907,7 @@ namespace ReactiveTests.Tests
             Assert.True(new[] { 1, 2, 3 }.SequenceEqual(lst));
         }
 
+#if !NO_THREAD
         [Fact]
         public void Delay_TimeSpan_Real_Error1()
         {
@@ -918,6 +919,7 @@ namespace ReactiveTests.Tests
         {
             Delay_TimeSpan_Real_Error1_Impl(ThreadPoolScheduler.Instance);
         }
+#endif
 
         private void Delay_TimeSpan_Real_Error1_Impl(IScheduler scheduler)
         {
@@ -943,6 +945,7 @@ namespace ReactiveTests.Tests
             Assert.Same(ex, err);
         }
 
+#if !NO_THREAD
         [Fact]
         public void Delay_TimeSpan_Real_Error2()
         {
@@ -954,6 +957,7 @@ namespace ReactiveTests.Tests
         {
             Delay_TimeSpan_Real_Error2_Impl(ThreadPoolScheduler.Instance);
         }
+#endif
 
         private void Delay_TimeSpan_Real_Error2_Impl(IScheduler scheduler)
         {
@@ -980,6 +984,7 @@ namespace ReactiveTests.Tests
             Assert.Same(ex, err);
         }
 
+#if !NO_THREAD
         [Fact]
         public void Delay_TimeSpan_Real_Error3()
         {
@@ -991,6 +996,7 @@ namespace ReactiveTests.Tests
         {
             Delay_TimeSpan_Real_Error3_Impl(ThreadPoolScheduler.Instance);
         }
+#endif
 
         private void Delay_TimeSpan_Real_Error3_Impl(IScheduler scheduler)
         {

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

@@ -1900,7 +1900,7 @@ namespace ReactiveTests.Tests
 
     public static class MyExt
     {
-
+#if !CRIPPLED_REFLECTION
         public static IQbservable<R> Foo<T, R>(this IQbservable<T> source, Expression<Func<T, R>> f)
         {
             return source.Provider.CreateQuery<R>(
@@ -1911,12 +1911,13 @@ namespace ReactiveTests.Tests
                 )
             );
         }
+#endif
 
         public static IObservable<R> Foo<T, R>(this IObservable<T> source, Func<T, R> f)
         {
             return source.Select(f);
         }
-
+#if !CRIPPLED_REFLECTION
         public static IQbservable<string> Bar(this IQbservable<int> source)
         {
             return source.Provider.CreateQuery<string>(
@@ -1927,11 +1928,13 @@ namespace ReactiveTests.Tests
             );
         }
 
+#endif
         public static IObservable<string> Bar(this IObservable<int> source)
         {
             return source.Select(x => new string('*', x));
         }
 
+#if !CRIPPLED_REFLECTION
         public static IQbservable<T> Qux<T>(this IQbservableProvider provider, T value)
         {
             return provider.CreateQuery<T>(
@@ -1942,12 +1945,14 @@ namespace ReactiveTests.Tests
                 )
             );
         }
+#endif
 
         public static IObservable<T> Qux<T>(T value)
         {
             return Observable.Return(value);
         }
 
+#if !CRIPPLED_REFLECTION
         public static IQbservable<R> Baz<T, R>(this IQbservable<T> source, Expression<Func<T, R>> f)
         {
             return source.Provider.CreateQuery<R>(
@@ -1958,6 +1963,7 @@ namespace ReactiveTests.Tests
                 )
             );
         }
+#endif
     }
 
     class MyQbservable<T> : IQbservable<T>

+ 2 - 2
Rx.NET/Source/Tests.System.Reactive/Tests/NotificationTest.cs

@@ -239,10 +239,10 @@ namespace ReactiveTests.Tests
             Assert.Equal("OK", res);
         }
 
-        [Fact, ExpectedException(typeof(ArgumentNullException))]
+        [Fact]
         public void OnError_CtorNull()
         {
-            Notification.CreateOnError<int>(null);
+            ReactiveAssert.Throws<ArgumentNullException>(() => Notification.CreateOnError<int>(null));
         }
 
         [Fact]

+ 2 - 1
Rx.NET/Source/Tests.System.Reactive/Tests/ObserverTest.cs

@@ -6,6 +6,7 @@ using System.Linq;
 using System.Reactive;
 using System.Reactive.Concurrency;
 using System.Threading;
+using System.Threading.Tasks;
 using Microsoft.Reactive.Testing;
 using Xunit;
 
@@ -813,7 +814,7 @@ namespace ReactiveTests.Tests
         {
             public override void Post(SendOrPostCallback d, object state)
             {
-                ThreadPool.QueueUserWorkItem(_ => d(state), state);
+                Task.Run(_ => d(state), state);
             }
         }
 

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

@@ -147,7 +147,7 @@ namespace ReactiveTests.Tests
             yield return 1;
         }
 #endif
-
+#if !NO_THREAD
         [Fact]
         [Timeout(1000)]
         public void Bug_1333()
@@ -159,6 +159,7 @@ namespace ReactiveTests.Tests
             d.OnCompleted();
             sema.WaitOne();
         }
+#endif
 #endif
 
         [Fact]

+ 4 - 3
Rx.NET/Source/Tests.System.Reactive/project.json

@@ -34,6 +34,7 @@
             "HAS_APTCA",
             "HAS_DISPATCHER",
             "HAS_DISPATCHER_PRIORITY",
+            "HAS_STACKTRACE",
             "HAS_WINFORMS",
             "USE_TIMER_SELF_ROOT"
         ]
@@ -41,13 +42,13 @@
       "dependencies": {
         "System.Reactive.Windows.Threading": { "target": "project" },
         "System.Reactive.Windows.Forms": { "target": "project" },
-        "System.Reactive.Runtime.Remoting": { "target": "project" },
-        "System.Threading.Timer": "4.0.0"
+        "System.Reactive.Runtime.Remoting": { "target": "project" }        
       },
       "frameworkAssemblies": {
         "System.Windows": "4.0.0.0",
         "WindowsBase": "4.0.0.0",
-        "System.Runtime": "4.0.0.0" 
+        "System.Runtime": "4.0.0.0",
+        "System.Threading.Tasks": "4.0.0.0"
       }
     },
     "dotnet5.1": {