public void Start(Action <CronTime> eventCallback) { try { Logger.Log($"{GetNowTimestampForLogging()} >>> Public start called"); _eventCallback = eventCallback; _internalStream = _cronTimeStream.AdvanceTo(_dateTimeRepository.Now()).GetEnumerator(); Run(); } catch (Exception e) { Debug.WriteLine(e); } }
public void Test1000Runs() { var cronTemplate = new CronTemplateBuilder().WithEverything().EveryXSeconds(2).Build(); var simpleCronStream = new CronTimeStreamSimple(cronTemplate, _dateTimeRepository.Now()); var reactiveScheduler = new ReactiveScheduler(_dateTimeRepository, _testScheduler, simpleCronStream, true); Logger.LogAction = Console.WriteLine; int callCount = 0; reactiveScheduler.SchedulerObservable.Subscribe(_ => callCount++); _testScheduler.AdvanceBy(TimeSpan.FromSeconds(2000).Ticks); callCount.Should().Be(1000); }
public void TestSimpleStream() { var callbackCount = 0; //Logger.LogAction = z => Debug.WriteLine(z); _simpleScheduler.Start((cronTime) => { Debug.WriteLine($"Client notified: {_dateTimeRepository.Now().ToString(DateTimeFormats.DatetimeFormatWithDayOfWeek)}"); callbackCount++; }); _testScheduler.AdvanceBy(TimeSpan.FromHours(91).Ticks); Debug.WriteLine($"Final Time: {_testScheduler.Now}"); Thread.Sleep(100); callbackCount.Should().Be(24); }
public CronSchedulerStreamReactiveTests() { _dateTimeRepository = new DateTimeRepositoryRx(_testScheduler); var breakTemplate = new CronTemplateBuilder() .WithMinutes(0, 15, 30) .WithHours(9, 14) .WithAllDaysOfMonth() .WithDaysOfWeek(1, 2, 3, 4, 5) .WithAllMonths() .Build(); _simpleStreamBase = new CronTimeStreamSimple(breakTemplate, _dateTimeRepository.Now()); _reactiveScheduler = new ReactiveScheduler( _dateTimeRepository, _testScheduler, _simpleStreamBase); }