public void TestNothingTill800ms() { // Run a test scheduler to put time under our control. new TestScheduler().With(s => { var fixture = new WebCallViewModel(new immediateWebService()); fixture.InputText = "hi"; // Run the clock forward to 800 ms. At that point, nothing should have happened. s.AdvanceToMs(799); Assert.Equal("", fixture.ResultText); // Run the clock 1 tick past and the result should show up. s.AdvanceToMs(801); Assert.Equal("result hi", fixture.ResultText); }); }
public void TestDelayAfterUpdate() { // Run a test scheduler to put time under our control. new TestScheduler().With(s => { var fixture = new WebCallViewModel(new immediateWebService()); fixture.InputText = "hi"; // Run the clock forward 300 ms, where they type again. s.AdvanceToMs(300); fixture.InputText = "there"; // Now, at 801, there should be nothing! s.AdvanceToMs(801); Assert.Equal("", fixture.ResultText); // But, at 800+300+1, our result shoudl appear! s.AdvanceToMs(800 + 300 + 1); Assert.Equal("result there", fixture.ResultText); }); }