Exemple #1
0
        public void Query_ForDifferentDateIntervals_ShoudReturnCorrectOverlapsCount(int leftEdgeMinutes, int rightEdgeMinutes, int expectedOverlapsCount)
        {
            //Arrange
            var intervals = new List <Interval <DateTime> >();

            intervals.Add(ToDateTimeInterval(now, -300, -200));
            intervals.Add(ToDateTimeInterval(now, -3, -2));
            intervals.Add(ToDateTimeInterval(now, 1, 2));
            intervals.Add(ToDateTimeInterval(now, 3, 6));
            intervals.Add(ToDateTimeInterval(now, 2, 4));
            intervals.Add(ToDateTimeInterval(now, 5, 7));
            intervals.Add(ToDateTimeInterval(now, 1, 3));
            intervals.Add(ToDateTimeInterval(now, 4, 6));
            intervals.Add(ToDateTimeInterval(now, 8, 9));
            intervals.Add(ToDateTimeInterval(now, 15, 20));
            intervals.Add(ToDateTimeInterval(now, 40, 50));
            intervals.Add(ToDateTimeInterval(now, 49, 60));

            IIntervalContainer <DateTime> intervalContainer = this.CreateIntervalContainer(intervals);

            //Act
            var overlaps = intervalContainer.Query(ToDateTimeInterval(now, leftEdgeMinutes, rightEdgeMinutes));

            //Assert
            Assert.AreEqual(expectedOverlapsCount, overlaps.Count());
        }
Exemple #2
0
        private IEnumerable <IInterval <DateTime> > TestQueryForInterval(Interval <DateTime> intervalToQuery, IIntervalContainer <DateTime> queryIn, string testName)
        {
            stopwatch.Reset();
            stopwatch.Start();

            var foundIntervals = queryIn.Query(intervalToQuery).ToList();

            stopwatch.Stop();
            timeEllapsedReport.AppendLine(string.Format("Time taken for {0}: {1} ms", testName, stopwatch.ElapsedMilliseconds));
            return(foundIntervals);
        }
        private IEnumerable<IInterval<DateTime>> TestSearchForInterval(DateTime startEdge, DateTime endEdge, IIntervalContainer<DateTime> searchIn, string testName)
        {
            stopwatch.Reset();
            stopwatch.Start();

            var foundIntervals = searchIn.Query(new Interval<DateTime>(startEdge, endEdge)).ToList();

            stopwatch.Stop();
            timeEllapsedReport.AppendLine(string.Format("Time taken for {0}: {1} ms", testName, stopwatch.ElapsedMilliseconds));
            return foundIntervals;
        }
Exemple #4
0
        public void Query_ForDifferentSideDateIntervals_ShoudReturnCorrectOverlapsCount(int leftEdgeMinutes, int rightEdgeMinutes, int expectedOverlapsCount)
        {
            //Arrange
            #region Specification
            // *************************************************************
            // | X axis:                                                   |
            // | 0    5    10   15   20   25   30   35   40   45   50    56|
            // | |    |    |    |    |    |    |    |    |    |    |     | |
            // | Container intervals:                                      |
            // | [-------------]      [-------------]      [-------------] |
            // |     [-----]              [-----]              [-----]     |
            // | Test intervals:                                           |
            // | [-]                                                       |
            // | [------]                                                  |
            // | [----------------------]                                  |
            // | [---------------------------]                             |
            // | [-------------------------------------------]             |
            // | [------------------------------------------------]        |
            // | [-------------------------------------------------------] |
            // |                                                       [-] |
            // |                                                  [------] |
            // |                                  [----------------------] |
            // |                             [---------------------------] |
            // |             [-------------------------------------------] |
            // |        [------------------------------------------------] |
            // | X axis:                                                   |
            // | |    |    |    |    |    |    |    |    |    |    |     | |
            // | 0    5    10   15   20   25   30   35   40   45   50    56|
            // *************************************************************
            #endregion

            var intervals = new List <Interval <DateTime> >();
            intervals.Add(ToDateTimeInterval(now, 0, 14));
            intervals.Add(ToDateTimeInterval(now, 4, 10));
            intervals.Add(ToDateTimeInterval(now, 21, 35));
            intervals.Add(ToDateTimeInterval(now, 25, 31));
            intervals.Add(ToDateTimeInterval(now, 42, 56));
            intervals.Add(ToDateTimeInterval(now, 46, 52));

            IIntervalContainer <DateTime> intervalContainer = this.CreateIntervalContainer(intervals);

            //Act
            var overlaps = intervalContainer.Query(ToDateTimeInterval(now, leftEdgeMinutes, rightEdgeMinutes));

            //Assert
            Assert.AreEqual(expectedOverlapsCount, overlaps.Count());
        }
        private IEnumerable<IInterval<DateTime>> TestQueryForInterval(Interval<DateTime> intervalToQuery, IIntervalContainer<DateTime> queryIn, string testName)
        {
            stopwatch.Reset();
            stopwatch.Start();

            var foundIntervals = queryIn.Query(intervalToQuery).ToList();

            stopwatch.Stop();
            timeEllapsedReport.AppendLine(string.Format("Time taken for {0}: {1} ms", testName, stopwatch.ElapsedMilliseconds));
            return foundIntervals;
        }
 public void Query_RigthEndInterval(IIntervalContainer<DateTime> container)
 {
     Interval<DateTime> queryInterval = this.ToDateTimeInterval(DateTime.Now, this.numberOfIntervals - 1, this.numberOfIntervals);
     container.Query(queryInterval).ToList();
 }
 public void Query_MinToMaxSpanningInterval(IIntervalContainer<DateTime> container)
 {
     Interval<DateTime> queryInterval = this.ToDateTimeInterval(DateTime.Now, -this.numberOfIntervals, this.numberOfIntervals);
     container.Query(queryInterval).ToList();
 }
 public void Query_MidInterval(IIntervalContainer<DateTime> container)
 {
     Interval<DateTime> queryInterval = this.ToDateTimeInterval(DateTime.Now, -1, 1);
     container.Query(queryInterval).ToList();
 }
Exemple #9
0
        public void Query_RigthEndInterval(IIntervalContainer <DateTime> container)
        {
            Interval <DateTime> queryInterval = this.ToDateTimeInterval(DateTime.Now, this.numberOfIntervals - 1, this.numberOfIntervals);

            container.Query(queryInterval).ToList();
        }
Exemple #10
0
        public void Query_MinToMaxSpanningInterval(IIntervalContainer <DateTime> container)
        {
            Interval <DateTime> queryInterval = this.ToDateTimeInterval(DateTime.Now, -this.numberOfIntervals, this.numberOfIntervals);

            container.Query(queryInterval).ToList();
        }
Exemple #11
0
        public void Query_MidInterval(IIntervalContainer <DateTime> container)
        {
            Interval <DateTime> queryInterval = this.ToDateTimeInterval(DateTime.Now, -1, 1);

            container.Query(queryInterval).ToList();
        }