dotnet / dotnet/reactive

Rationalise TestScheduler.Start() overloads

Open
#81 3 comments 3 reactions 0 assignees View on GitHub
[area] Rx needs design suggestion
Dominant language
C#
Stars
7.2k
Forks
798
PR merge metrics
No merged PRs in 30d

Description

I have had a concern that the three overloads of `TestScheduler.Start()` all seem to do slightly different things.

The `Start()` method inherited from `VirtualTimeScheduler` simply drains the scheduled items from the queue until empty or until `Stop()` is called.

The `Start(Func>,..)` methods however create an Observable sequence from the provided function and will execute the creation, subscription and unsubscription at given times.
It then returns the `ITestableObserver` that will be subscribed to the created observable sequence.
While I can see this as being useful, I do find it odd that these methods share the same method name as the method from the base class `VirtualTimeScheduler`.
I also find the use of seemingly random default values for create/subscribe/dispose times coming from ReactiveTest.Create/Subscribed/Disposed to be surprising.
Showing these methods to other developers, they have also tended to agree that "magic numbers" were in direct conflict with the principle of least surprise.
These numbers assume that 100, 200 and 1000 ticks are appropriate values or even in the appropriate order of magnitude for testing in everyone's domain - which is surely nonsense?

My point is that one `Start()` method drains the scheduler's queue, the other creates things, schedules things, returns things, and calls that `Start()` method.

My suggestions are
- to drop the magic numbers and the overloads that use them.
- rename either `VirtualTimeScheduler.Start()` and `VirtualTimeScheduler.Stop` to `VirtualTimeScheduler.Run()` and `VirtualTimeScheduler.Pause()` or rename `TestScheduler.Start` to `TestScheduler.Run`(?)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.