public void testPeriodic() { TestExecutor exec = NET.Executors.NewTest(); exec.Schedule(() => Console.WriteLine(exec.Now), TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1)); exec.AdvanceTimeBy(TimeSpan.FromSeconds(10)); }
public void NormalConditional() { var tex = new TestExecutor(); var dp = new DirectProcessor <int>(); var ts = dp.ThrottleFirst(TimeSpan.FromMilliseconds(5), tex).Filter(v => true).Test(); ts.AssertEmpty(); dp.OnNext(1); ts.AssertValues(1) .AssertNoError() .AssertNotComplete(); dp.OnNext(2); ts.AssertValues(1) .AssertNoError() .AssertNotComplete(); tex.AdvanceTimeBy(TimeSpan.FromMilliseconds(5)); ts.AssertValues(1) .AssertNoError() .AssertNotComplete(); dp.OnNext(3); ts.AssertValues(1, 3) .AssertNoError() .AssertNotComplete(); dp.OnNext(4); dp.OnComplete(); ts.AssertResult(1, 3); tex.AdvanceTimeBy(TimeSpan.FromMilliseconds(5)); ts.AssertResult(1, 3); }
public void test() { TestExecutor exec = NET.Executors.NewTest(); for (int i = 0; i < 10; i++) { exec.Schedule(() => Console.WriteLine(exec.Now), TimeSpan.FromSeconds(i)); } exec.AdvanceTimeBy(TimeSpan.FromSeconds(10)); }
public void Lockstep() { var tex = new TestExecutor(); var dp = new DirectProcessor <int>(); var ts = dp.Debounce(TimeSpan.FromMilliseconds(5), tex).Test(); ts.AssertEmpty(); dp.OnNext(1); ts.AssertEmpty(); tex.AdvanceTimeBy(TimeSpan.FromMilliseconds(5)); ts.AssertValues(1) .AssertNoError() .AssertNotComplete(); dp.OnNext(2); ts.AssertValues(1) .AssertNoError() .AssertNotComplete(); tex.AdvanceTimeBy(TimeSpan.FromMilliseconds(2)); ts.AssertValues(1) .AssertNoError() .AssertNotComplete(); dp.OnNext(3); tex.AdvanceTimeBy(TimeSpan.FromMilliseconds(5)); ts.AssertValues(1, 3) .AssertNoError() .AssertNotComplete(); tex.AdvanceTimeBy(TimeSpan.FromMilliseconds(2)); dp.OnNext(4); tex.AdvanceTimeBy(TimeSpan.FromMilliseconds(2)); dp.OnComplete(); tex.AdvanceTimeBy(TimeSpan.FromMilliseconds(1)); ts.AssertResult(1, 3, 4); }