示例#1
0
        public void TestValidate()
        {
            // Test all units missing
            IDictionary <ScheduleUnit, ICollection <int> > unitValues = new Dictionary <ScheduleUnit, ICollection <int> >();

            AssertInvalid(unitValues);

            // Test one unit missing
            unitValues = new ScheduleSpec().UnitValues;
            unitValues.Remove(ScheduleUnit.HOURS);
            AssertInvalid(unitValues);

            // Test all units are wildcards
            unitValues = new ScheduleSpec().UnitValues;
            new ScheduleSpec(unitValues, null, null, null);

            // Test invalid value in month
            ICollection <int> values = new SortedSet <int>();

            values.Add(0);
            unitValues.Put(ScheduleUnit.MONTHS, values);
            AssertInvalid(unitValues);

            // Test valid value in month
            values = new SortedSet <int>();
            values.Add(1);
            values.Add(5);
            unitValues.Put(ScheduleUnit.MONTHS, values);
            new ScheduleSpec(unitValues, null, null, null);
        }
示例#2
0
        public void TestCompress()
        {
            IDictionary <ScheduleUnit, ICollection <int> > unitValues = new Dictionary <ScheduleUnit, ICollection <int> >();

            unitValues = new ScheduleSpec().UnitValues;

            // Populate Month with all valid values
            ICollection <int> monthValues = new SortedSet <int>();

            for (var i = ScheduleUnit.MONTHS.Min(); i <= ScheduleUnit.MONTHS.Max(); i++)
            {
                monthValues.Add(i);
            }

            unitValues.Put(ScheduleUnit.MONTHS, monthValues);

            // Construct spec, test that month was replaced with wildcards
            var spec = new ScheduleSpec(unitValues, null, null, null);

            Assert.IsTrue(spec.UnitValues.Get(ScheduleUnit.MONTHS) == null);
        }