Permalink
Browse files

100% green RxUI tests

  • Loading branch information...
1 parent 0fdc1b1 commit 80c15afdd340bad32608bdd88fd991900c3b0057 @paulcbetts paulcbetts committed Mar 23, 2012
@@ -19,7 +19,7 @@ public class ErrorsTest
public void UnhandledUserErrorsShouldDie()
{
// Since we haven't registered any user error handler
- Assert.Throws<UnhandledUserErrorException>(() => UserError.Throw("Something Bad Has Happened"));
+ Assert.Throws<UnhandledUserErrorException>(() => UserError.Throw("Something Bad Has Happened").First());
}
[Fact]
@@ -30,7 +30,7 @@ public void HandledUserErrorsShouldNotThrow()
Assert.Equal(RecoveryOptionResult.RetryOperation, result);
}
- Assert.Throws<UnhandledUserErrorException>(() => UserError.Throw("This should throw!"));
+ Assert.Throws<UnhandledUserErrorException>(() => UserError.Throw("This should throw!").First());
}
[Fact]
@@ -48,20 +48,20 @@ public void NestedHandlersShouldFireInANestedWay()
Assert.Equal(RecoveryOptionResult.CancelOperation, result);
}
- Assert.Throws<UnhandledUserErrorException>(() => UserError.Throw("This should throw!"));
+ Assert.Throws<UnhandledUserErrorException>(() => UserError.Throw("This should throw!").First());
}
[Fact]
public void TypeSpecificFiltersShouldntFireOnOtherExceptions()
{
using (UserError.RegisterHandler<MyAwesomeUserError>(x => Observable.Return(RecoveryOptionResult.CancelOperation))) {
var result = UserError.Throw(new MyAwesomeUserError()).First();
- Assert.Equal(RecoveryOptionResult.RetryOperation, result);
+ Assert.Equal(RecoveryOptionResult.CancelOperation, result);
- Assert.Throws<UnhandledUserErrorException>(() => UserError.Throw("This should throw!"));
+ Assert.Throws<UnhandledUserErrorException>(() => UserError.Throw("This should throw!").First());
}
- Assert.Throws<UnhandledUserErrorException>(() => UserError.Throw(new MyAwesomeUserError()));
+ Assert.Throws<UnhandledUserErrorException>(() => UserError.Throw(new MyAwesomeUserError()).First());
}
}
}
@@ -59,10 +59,13 @@ public void OAPHShouldRethrowErrors()
var fixture = new ObservableAsPropertyHelper<int>(input,
_ => { }, -5, sched);
+ var errors = new List<Exception>();
Assert.Equal(-5, fixture.Value);
(new[] { 1, 2, 3, 4 }).Run(x => input.OnNext(x));
+ fixture.ThrownExceptions.Subscribe(errors.Add);
+
sched.Start();
Assert.Equal(4, fixture.Value);
@@ -71,12 +74,8 @@ public void OAPHShouldRethrowErrors()
sched.Start();
- try {
- Assert.Equal(4, fixture.Value);
- } catch {
- return;
- }
- Assert.True(false, "We should've threw there");
+ Assert.Equal(4, fixture.Value);
+ Assert.Equal(1, errors.Count);
}
[Fact]
@@ -248,42 +248,6 @@ public void RegisterMemoizedFunctionSmokeTest()
}
[Fact]
- public void MakeSureMemoizedReleaseFuncGetsCalled()
- {
- //Assert.True(false, "When an item gets evicted from the cache before it has a chance to complete, it deadlocks. Fix it.");
- var input = new[] { 1, 1, 2, 2, 1, 1, 3, 3 };
-
- var sched = new EventLoopScheduler();
- var fixture = new ReactiveAsyncCommand();
- var results = new List<Timestamped<int>>();
- var released = new List<int>();
-
- fixture.RegisterMemoizedFunction(x => { Thread.Sleep(250); return ((int)x) * 5; }, 2, x => released.Add(x), sched)
- .Timestamp()
- .Subscribe(x => results.Add(x));
-
- Assert.True(fixture.CanExecute(1));
-
- var start = DateTimeOffset.Now;
- foreach(var i in input) {
- Assert.True(fixture.CanExecute(i));
- fixture.Execute(i);
- }
-
- Thread.Sleep(1000);
-
- results.Select(x => x.Timestamp - start)
- .Run(x => { });
-
- released.Run(x => { });
-
- Assert.True(results.Count == 8);
-
- Assert.True(released.Count == 1);
- Assert.True(released[0] == 2*5);
- }
-
- [Fact]
public void MultipleSubscribersShouldntDecrementRefcountBelowZero()
{
(new TestScheduler()).With(sched => {

0 comments on commit 80c15af

Please sign in to comment.