Skip to content

[Bug]: RxSchedulers do not work with TestScheduler #4183

@Cheesebaron

Description

@Cheesebaron

Describe the bug 🐞

When using RxSchedulers in a Unit Test scenario with the combination of Microsoft.Reactive.Testing.TestScheduler and the With extension method, it doesn't properly set the RxScheduler.MainThreadScheduler and RxScheduler.TaskpoolScheduler to the TestScheduler. When looking at RxApp.MainThreadScheduler and RxApp.TaskPoolScheduler they are correctly set to TestScheduler

Step to reproduce

Create a unit test with a body like:

using Microsoft.Reactive.Testing;
using ReactiveUI.Testing;
using Xunit;

public class TestClass : ReactiveTest
{
    [Fact]
    public void Test()
    {
        // check RxApp MainThreadSheduler and TaskPoolScheduler
        // and RxScheduler MainThreadScheduler and TaskpoolScheduler
        // they all be be: System.Reactive.Concurrency.CurrentThreadScheduler

        new TestScheduler().With(scheduler =>
        {
            // check RxApp MainThreadSheduler and TaskPoolScheduler
            // they will be be be: Microsoft.Reactive.Testing.TestScheduler

            // and RxScheduler MainThreadScheduler and TaskpoolScheduler
            // they will be be: System.Reactive.Concurrency.CurrentThreadScheduler
        });
    }
}

In the body of that With block RxApp schedulers are TestScheduler but RxSchedulers are System.Reactive.Concurrency.DefaultScheduler

Expected behavior

TestScheduler should also be set on RxSchedulers when running in unit tests

Screenshots 🖼️

No response

IDE

Visual Studio Code

Operating system

macos

Version

No response

Device

No response

ReactiveUI Version

22.1.1

Additional information ℹ️

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions