reactive async assertions
See original GitHub issueWe have a system where components embedded in a runtime mainly communicate with each other through events. To test these components (or to specifiy its behavior) I’d like to see more assertions that deal with handling a series of events (asynchronously or synchronously).
Here are some examples:
// assert number of events
sut.ShouldRaiseEvent("SomethingHappened").Exacly.Once;
sut.ShouldRaiseEvent("SomethingHappened").AtLeast(5).Times;
sut.ShouldRaiseEvent("SomethingHappened").NotMoreThan(6).Times;
// assert sequence of events
sut.ShouldRaiseEvent("SomethingHappened").FollowedBy("SomethingElseHappened");
sut.ShouldRaiseEvent("SomethingHappened").WithArgs<SomethingEventArgs>(a => a.Foo = "Bar").FollowedBy("SomethingHappened").WithArgs<SomethingEventArgs>(a => a.Foo = "Bar2");
sut.ShouldRaiseEvent("SomethingHappened").AtLeast(5).Times.FollowedBy("SomethingElseHappened");
sut.ShouldRaiseEvent("SomethingHappened").AtLeast(5).Times.FollowedBy("SomethingHappened").WithArgs<SomethingEventArgs>(a => a.Foo = "Bar");
// assert all of the above in an asynchronous fashion (obvoiously you'd often want a timeout here)
await sut.ShouldRaiseEvent("SomethingHappened").Exactly.Once.Within(Timespan.FromSeconds(1));
// but also without a timeout is possible
await sut.ShouldRaiseEvent("SomethingHappened").Exactly.Once.Eventually;
Issue Analytics
- State:
- Created 9 years ago
- Comments:20 (10 by maintainers)
Top Results From Across the Web
Reactive Asynchronous Programming in Java using ...
In Reactive Streams and Reactor, errors are terminal events. As soon as an error occurs, it stops the sequence and gets propagated down...
Read more >Async method deadlocks with TestScheduler in ReactiveUI
The test hangs when the async call is awaited. The root cause seems to be a command that's awaited in the async method....
Read more >Lazy and async assertions | Better world by better software
I use assertions in my production code for two reasons. Users always find new ways to go beyond what I expect and test...
Read more >Testing Asynchronous Code • Angular
This async function executes the code inside its body in a special async test zone. This intercepts and keeps track of all promises...
Read more >CreateCollection + Testing - pasoft-share/ReactiveUI
Rx lets you easily control the ordering of events to happen in arbitrary combinations that happen in a deterministic way. This means that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I guess it is important that I still can use whatever version of reactive extension I choose in the same Appdomain that the tests run in, because the SUT itself might depend on it.
Yeah, but it’s a big feature. I welcome Pull Requests though 😏