ReactiveUI.Samples/testing
RLittlesII d3e4dcff62
Moved READMe to platform pages
2019-08-10 16:17:23 -05:00
..
ReactiveUI.Samples.Testing.SimpleViewModels feature: Add Avalonia sample, improve README.md (#31) 2019-07-02 00:48:00 +03:00
ReactiveUI.Samples.Testing.SimpleViewModels.Tests feature: Add Avalonia sample, improve README.md (#31) 2019-07-02 00:48:00 +03:00
README.MD Moved READMe to platform pages 2019-08-10 16:17:23 -05:00
ReactiveUI.Samples.Testing.SimpleViewModels.sln feature: Add Avalonia sample, improve README.md (#31) 2019-07-02 00:48:00 +03:00

README.MD

ReactiveUI.Samples.Testing.SimpleViewModels

Illustrates how to write testable and maintainable view models using ReactiveUI.Testing, XUnit and Microsoft.Reactive.Testing libraries. See related documentation. Contains immediate scheduling examples to make the tests run even faster by mocking long-running operations.

new TestScheduler().With(scheduler =>
{
    var fixture = new WebCallViewModel(new ImmediateWebService());
    fixture.InputText = "hi";

    // Run the clock forward to 800 ms. 
    // At that point, nothing should have happened.
    scheduler.AdvanceToMs(799);
    Assert.Equal(string.Empty, fixture.ResultText);

    // Run the clock 1 tick past and the result should show up.
    scheduler.AdvanceToMs(801);
    Assert.Equal("result hi", fixture.ResultText);
});