Skip to content

TestScheduler throws NullReferenceException when subscribed is less than created #1114

@NickLydon

Description

@NickLydon

Hello and thank you for using dotnet/reactive. Please select a category and detail your issue by answering the questions there:

Bug

Despite our best efforts, bugs can slip into releases or corner cases forgotten about. We will try our best to remedy the situation
and/or provide workarounds. Note that certain (odd) behaviors are by design and as such are not considered bugs.

Which library version?

4.3.1

What are the platform(s), environment(s) and related component version(s)?

windows, netcoreapp2.2, XUnit tests

What is the use case or problem?

Using the TestScheduler Start overload Start<T>(Func<IObservable<T>> create, long created, long subscribed, long disposed) with a subscribed value lower than the created throws a null reference exception

What is the expected outcome?

Perhaps throwing an argument exception before it gets to that point?

What is the actual outcome?

null reference exception

What is the stacktrace of the exception(s) if any?

System.NullReferenceException : Object reference not set to an instance of an object.
   at Microsoft.Reactive.Testing.TestScheduler.<>c__DisplayClass4_0`1.<Start>b__1(IScheduler scheduler, Object state) in d:\a\1\s\Rx.NET\Source\src\Microsoft.Reactive.Testing\TestScheduler.cs:line 94
   at System.Reactive.Concurrency.VirtualTimeScheduler`2.<>c__DisplayClass4_0`1.<ScheduleAbsolute>b__0(IScheduler scheduler, TState state1) in d:\a\1\s\Rx.NET\Source\src\System.Reactive\Concurrency\VirtualTimeScheduler.cs:line 430
   at System.Reactive.Concurrency.ScheduledItem`1.Invoke() in d:\a\1\s\Rx.NET\Source\src\System.Reactive\Concurrency\ScheduledItem.cs:line 44
   at System.Reactive.Concurrency.VirtualTimeSchedulerBase`2.Start() in d:\a\1\s\Rx.NET\Source\src\System.Reactive\Concurrency\VirtualTimeScheduler.cs:line 174
   at Microsoft.Reactive.Testing.TestScheduler.Start[T](Func`1 create, Int64 created, Int64 subscribed, Int64 disposed) in d:\a\1\s\Rx.NET\Source\src\Microsoft.Reactive.Testing\TestScheduler.cs:line 97

Do you have a code snippet or project that reproduces the problem?

new TestScheduler().Start(
  () => Observable.Empty<int>(),
  100,
  99,
  1000
);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions