private static void TestTimeSection(ICron cron, ISection section) { section.Add(1) .Every.Should() .BeFalse(); cron.Add(section.Time, 2); section.Every.Should() .BeFalse(); cron.Add(section.Time, 3, true); section.Every.Should() .BeTrue(); }
public SeasonalAvatar(ICron cron, DiscordSocketClient discord, Configuration config) { _cron = cron; _discord = discord; _rng = new Random(); if (config.Avatar?.Avatars == null) { return; } _config = config.Avatar.Avatars; }
private static void TestDateSection(ICron cron, ISection section) { section.Add(1) .Every.Should() .BeFalse(); cron.Add(section.Time, 2); section.Every.Should() .BeFalse(); Action act = () => cron.Add(section.Time, 3, true); act.Should() .Throw <Exception>(); }
public DirectoryWatcher(IDebugger debugger, IUnixTime unixTime, ICron cron) { // ... (_debugger = debugger).Trace(); _unixTime = unixTime; _cron = cron; // Registering cron-task _cronTaskIdentifier = _cron.Register(FileSystemWatcherCheck, 30); // ... _queue = new Queue <string>(); _directories = new Dictionary <string, int>(); }
public DbMessages(IDatabase database, ICron cron, IChallenges challenges, DiscordSocketClient client) { _database = database; _cron = cron; _challenges = challenges; _client = client; try { _database.Exec("CREATE TABLE IF NOT EXISTS `Messages` (`ChannelID` INTEGER NOT NULL, `MessageID` INTEGER NOT NULL, `ChallengeID` INTEGER NOT NULL, `MessageType` INTEGER NOT NULL, PRIMARY KEY(`MessageID`, `ChallengeID`))"); } catch (Exception e) { Console.WriteLine(e); } }
public void Cron_CanVerifyComplex( int seconds, int dayMonth, int years, string expectedValue, string expectedDescription) { schedule = new CronBuilder() .Add(time: CronTimeSections.Seconds, value: seconds, repeatEvery: true) .Add(CronTimeSections.Minutes, 4) .Add(CronTimeSections.Minutes, 3, true) .Add(CronTimeSections.Hours, 3, 5) .Add(CronTimeSections.Hours, 7, 11) .Add(CronMonths.March) .Add(CronDays.Wednesday) .Add(CronDays.Friday) .Add(CronTimeSections.DayMonth, dayMonth); if (years > 0) { schedule.Add(CronTimeSections.Years, years); } schedule.Seconds.Select(x => x.MinValue) .First() .Should() .Be(seconds); schedule.Minutes.Select(x => x.MinValue) .ToList() .Should() .NotBeEmpty() .And.HaveCount(2) .And.Contain(3) .And.Contain(4); schedule.Hours .ToList() .Should() .NotBeEmpty() .And.HaveCount(2) .And.Contain(x => x.MinValue == 3 && x.MaxValue == 5) .And.Contain(x => x.MinValue == 7 && x.MaxValue == 11); schedule.Months.Select(x => x.MinValue) .First() .Should() .Be(3); schedule.DayWeek.Select(x => x.MinValue) .Should() .NotBeEmpty() .And.HaveCount(2) .And.Contain(3) .And.Contain(5); schedule.DayMonth.Select(x => x.MinValue) .First() .Should() .Be(dayMonth); if (years > 0) { schedule.Years.Select(x => x.MinValue) .First() .Should() .Be(years); } schedule.Value .Should() .Be(expectedValue); schedule.Description .Should() .Be(expectedDescription); schedule.Seconds.Every.Should() .BeTrue(); schedule.Minutes.Every.Should() .BeTrue(); schedule.Hours.Every.Should() .BeFalse(); schedule.Seconds.ToString() .Should() .Be($"*/{seconds}"); schedule.DayMonth.ToString() .Should() .Be($"{dayMonth}"); }
public void Init() => schedule = new CronBuilder();
public SchedulerStatus(ICron cron, IChallenges challenges, DiscordSocketClient client) { _cron = cron; _challenges = challenges; _client = client; }
public Competition(IChallenges challenges, IScheduler scheduler, ICron cron) { _challenges = challenges; _scheduler = scheduler; _cron = cron; }