public IEnumerable <TimedEvent> GetRange(DateTime RangeStart, DateTime RangeEnd) { int Index = 1; IEnumerator <int> IndicesIter = IntSpec.Parse(_IndexSpec, 1, int.MaxValue).GetEnumerator(); // If no indices, return if (!IndicesIter.MoveNext()) { yield break; } int NextIndex = IndicesIter.Current; // Iterate over each event, increment index until a match foreach (var Evt in _Schedule.GetRange(RangeStart, RangeEnd)) { // If index matches next, return the event if (Index == NextIndex) { yield return(Evt); if (!IndicesIter.MoveNext()) { yield break; } NextIndex = IndicesIter.Current; } Index++; } yield break; }
public void Run() { Debug.WriteLine("Unit test: " + Name); Debug.WriteLine("IntSpec expression: " + Spec); var actualResult = RangeStart.HasValue && RangeEnd.HasValue ? IntSpec.Parse(Spec, RangeStart.Value, RangeEnd.Value) : IntSpec.Parse(Spec); SequenceComparer.AssertCompare(ExpectedResult, actualResult, (a, b) => a.CompareTo(b)); // Success, exact match }