예제 #1
0
        public ISchedule Create()
        {
            var intersection     = new TemporalExpressionIntersection();
            var frequencyBuilder = EventFrequencyBuilder.Create(Schedule.FrequencyType);
            var union            = frequencyBuilder.Create(Schedule);

            intersection.Add(union);
            intersection.Add(Schedule.RangeInYear);

            var difference = new TemporalExpressionDifference(intersection, Schedule.ExcludedDates);

            Schedule.SetSchedule(difference);
            return(Schedule);
        }
        public void temporal_expression_intersection_matches_expected_dates()
        {
            // 2nd Monday and 2nd Thursday of the month.
            var te = new TemporalExpressionIntersection(new List<ITemporalExpression>
            {
                new DayInMonth(1, 1),
                new RangeInYear(4, 1, 6, 30),  
            });

            var incudedDt = DateTime.SpecifyKind(new DateTime(2016, 05, 09), DateTimeKind.Utc);
            var incuded2Dt = DateTime.SpecifyKind(new DateTime(2016, 06, 13), DateTimeKind.Utc);
            var excludedDt = DateTime.SpecifyKind(new DateTime(2016, 02, 10), DateTimeKind.Utc);
            var excluded2Dt = DateTime.SpecifyKind(new DateTime(2016, 06, 11), DateTimeKind.Utc);

            Assert.That(te.Includes(incudedDt));
            Assert.That(te.Includes(incuded2Dt));
            Assert.That(te.Includes(excludedDt), Is.False);
            Assert.That(te.Includes(excluded2Dt), Is.False);
        }