public void Start_Stop() { var s = new HistoricalScheduler(); var list = new List <Timestamped <int> >(); var ts = TimeSpan.FromHours(1); s.Schedule(Time(0), () => list.Add(new Timestamped <int>(1, s.Now))); s.Schedule(Time(1), () => list.Add(new Timestamped <int>(2, s.Now))); s.Schedule(Time(2), () => s.Stop()); s.Schedule(Time(3), () => list.Add(new Timestamped <int>(3, s.Now))); s.Schedule(Time(4), () => s.Stop()); s.Schedule(Time(5), () => s.Start()); s.Schedule(Time(6), () => list.Add(new Timestamped <int>(4, s.Now))); s.Start(); Assert.Equal(Time(2), s.Now); Assert.Equal(Time(2), s.Clock); s.Start(); Assert.Equal(Time(4), s.Now); Assert.Equal(Time(4), s.Clock); s.Start(); Assert.Equal(Time(6), s.Now); Assert.Equal(Time(6), s.Clock); s.Start(); Assert.Equal(Time(6), s.Now); Assert.Equal(Time(6), s.Clock); list.AssertEqual( new Timestamped <int>(1, Time(0)), new Timestamped <int>(2, Time(1)), new Timestamped <int>(3, Time(3)), new Timestamped <int>(4, Time(6)) ); }
public void IsEnabled() { var s = new HistoricalScheduler(); Assert.Equal(false, s.IsEnabled); s.Schedule(() => { Assert.Equal(true, s.IsEnabled); s.Stop(); Assert.Equal(false, s.IsEnabled); }); Assert.Equal(false, s.IsEnabled); s.Start(); Assert.Equal(false, s.IsEnabled); }