public void OnTimeManagerTick_WhenSomeTimes_RaiseExpectedEventCount(int addedMilliseconds, int tickCount, int expectedEventCount) { var scheduleProvider = new FakeScheduleProvider(); var schedule = scheduleProvider.GetSchedule(); scheduleProvider.Shedule = schedule; var timeManager = new FakeTimeManager(); int eventCount = 0; var engine = CreateEngine(timeManager, scheduleProvider); engine.PlaneArrived += (s, a) => eventCount++; engine.PlaneDepartured += (s, a) => eventCount++; engine.Start(); var time = TimeSpan.Zero; for (var i = 0; i < tickCount; i++) { time += TimeSpan.FromMilliseconds(addedMilliseconds); if (time.Days > 0) { time = time.Subtract(TimeSpan.FromDays(time.Days)); } timeManager.RaiseTick(new TickEventArgs { Time = time }); } Assert.AreEqual(expectedEventCount, eventCount); }
public void OnTimeManagerTick_WhenExistsFlights_RaiseExpectedEvent(int addedMilliseconds, int expectedArrived, int expectedDepartured) { var scheduleProvider = new FakeScheduleProvider(); var schedule = scheduleProvider.GetSchedule(); scheduleProvider.Shedule = schedule; var timeManager = new FakeTimeManager(); int arrived = 0; int departured = 0; var engine = CreateEngine(timeManager, scheduleProvider); engine.PlaneArrived += (s, a) => arrived++; engine.PlaneDepartured += (s, a) => departured++; engine.Start(); timeManager.RaiseTick(new TickEventArgs { Time = schedule.Flights.First().Time.Add(TimeSpan.FromMilliseconds(addedMilliseconds)) }); Assert.AreEqual(expectedArrived, arrived); Assert.AreEqual(expectedDepartured, departured); }