Ejemplo n.º 1
0
        public void SimpleTest()
        {
            var stream            = CronStream.CreateSchedule(DaysOfWeek.Monday, "9p");
            var streamCombination = new CronTimeStreamCombination(_dateTime, stream);

            foreach (var time in streamCombination.Take(10))
            {
                PrintTime(time);
            }
        }
        public void CronTimeGeneratorTests()
        {
            DateTime _dateTime = new DateTime(2016, 01, 01, 0, 0, 1);
            var      stream    = (CronTimeStreamComplex)CronStream.CreateSchedule(DaysOfWeek.Monday, "9p");
            var      template  = stream.CronTemplates.First();
            var      times     = CronTimeGenerator.Generate(_dateTime, template).Take(10).ToList();

            Debug.WriteLine(times[0].DateTime.Value.ToString("yyyy-MM-dd ddd  hh:mm:ss tt"));

            times[0].DateTime.Value.Should().Be(new DateTime(2016, 01, 04, 21, 0, 0));
            times[1].DateTime.Value.Should().Be(new DateTime(2016, 01, 11, 21, 0, 0));
        }
Ejemplo n.º 3
0
        public void TestNextDaySchedule()
        {
            var stream = CronStream.CreateSchedule(DaysOfWeek.Monday | DaysOfWeek.Tuesday,
                                                   "10p, 3a",
                                                   new DateTime(2016, 04, 11, 01, 01, 00));
            var results = stream.Take(5).ToList();

            results[0].DateTime.Should().Be(new DateTime(2016, 04, 11, 22, 0, 0));
            results[1].DateTime.Should().Be(new DateTime(2016, 04, 12, 03, 0, 0));
            results[2].DateTime.Should().Be(new DateTime(2016, 04, 12, 22, 0, 0));
            results[3].DateTime.Should().Be(new DateTime(2016, 04, 13, 03, 0, 0));
            results[4].DateTime.Should().Be(new DateTime(2016, 04, 18, 22, 0, 0));

            foreach (var time in stream.Take(200))
            {
                PrintTime(time);
            }
        }