Example #1
0
        public void TestTriggerAdvanced()
        {
            // rows
            var schedule = new[] {
                new Schedule { StartDate = DateTime.Parse("6/1/2014"), Name = "Item 1", Triggers = TriggerCollectionEx.Parse("Monthly"), Span = NumberSpan.Parse("0 of 12") },
                new Schedule { StartDate = DateTime.Parse("6/1/2014"), Name = "Item 2", Triggers = TriggerCollectionEx.Parse("Monthly"), Span = NumberSpan.Parse("0 of 6") } ,
                new Schedule { StartDate = DateTime.Parse("6/1/2014"), Name = "Item 3", Triggers = TriggerCollectionEx.Parse("Daily"), Span = NumberSpan.Parse("0 of 6") } };

            // expand
            var r = schedule.SelectMany(x => x.Triggers.SelectDates(y => new
            {
                StartDate = x.StartDate.ToShortDateString(),
                Date = y.ToShortDateString(),
                Span = ++x.Span
            }).Take(20), (a, b) => new
            {
                a.StartDate,
                a.Name,
                b.Date,
                b.Span,
            }).ToList();
            // results
            var c = r.Count;
        }
Example #2
0
 public void TestTriggerCollectionSelect()
 {
     var a = new TimeTrigger { StartBoundary = DateTime.Parse("12/7/2014 6:00 PM") };
     a.Repetition.Interval = new TimeSpan(1, 0, 0);
     a.Repetition.Duration = new TimeSpan(3, 0, 0);
     var b = new TimeTrigger { StartBoundary = DateTime.Parse("12/7/2014 6:00 PM") };
     b.Repetition.Interval = new TimeSpan(0, 1, 0);
     b.Repetition.Duration = new TimeSpan(3, 0, 0);
     var span1 = new[] { a, b };
     var r = span1.SelectDates(x => x).Take(6).ToArray();
     Debug.Assert(r.Length == 6);
     //Debug.Assert(r[0].Date.Month == 2);
     //Debug.Assert(r[0].TimeOfDay == new TimeSpan(18, 0, 0));
     //Debug.Assert(r[1].Date == r[0].Date);
     //Debug.Assert(r[1].TimeOfDay == new TimeSpan(19, 0, 0));
     //Debug.Assert(r[2].Date == r[1].Date);
     //Debug.Assert(r[2].TimeOfDay == new TimeSpan(20, 0, 0));
     //Debug.Assert(r[3].Date == r[2].Date.AddYears(1));
     //Debug.Assert(r[3].TimeOfDay == new TimeSpan(18, 0, 0));
     //Debug.Assert(r[4].Date == r[3].Date);
     //Debug.Assert(r[4].TimeOfDay == new TimeSpan(19, 0, 0));
     //Debug.Assert(r[5].Date == r[4].Date);
     //Debug.Assert(r[5].TimeOfDay == new TimeSpan(20, 0, 0));
 }