public virtual void TestDoubleSetToEnd()
        {
            InsertDefaultEntryByIndex(0);
            ITimeSeriesEntryCursor cursor = CreateCursor();

            cursor.SetToEnd();
            Assert.IsNull(cursor.Current);
            Assert.IsTrue(cursor.MovePrevious());
            ITimeSeriesEntry entry = cursor.Current;

            cursor.SetToEnd();
            Assert.IsTrue(cursor.MovePrevious());
            Assert.IsTrue(TimeSeriesComparisons.CompareTimeSeriesEntry(entry, cursor.Current));
        }
        public void TestSetToEndAtMaxValue()
        {
            InsertDefaultEntryByTimeStamp(MaximumTimeStamp);

            ITimeSeriesEntryCursor cursor = CreateCursor();

            cursor.SetToEnd();
            Assert.IsNull(cursor.Current);
            Assert.IsTrue(cursor.MovePrevious());
            CheckEntry(cursor.Current);
        }
        public virtual void TestWalkingMilesAfterEnd()
        {
            ITimeSeriesEntryCursor cursor = CreateCursor();

            InsertAllDefaultEntries();

            cursor.SetToEnd();
            Assert.IsNull(cursor.Current);

            // you cannot reach a valid entry behind the end
            for (int i = 1; i < 20; ++i)
            {
                Assert.IsFalse(cursor.MoveNext());
            }

            // one step must be enough to get to the last entry
            Assert.IsTrue(cursor.MovePrevious());
            Assert.IsNotNull(cursor.Current);
        }
        public virtual void TestCurrentBeforeStartOrBehindEnd()
        {
            ITimeSeriesEntryCursor cursor = CreateCursor();

            InsertAllDefaultEntries();

            cursor.SetToStart();
            Assert.IsNull(cursor.Current);

            ITimeSeriesEntry timeSeriesEntry = cursor.Current;

            Assert.IsNull(timeSeriesEntry);


            cursor.SetToEnd();
            Assert.IsNull(cursor.Current);

            timeSeriesEntry = cursor.Current;
            Assert.IsNull(timeSeriesEntry);
        }
        public virtual void TestSeekTimeStampBehindEnd()
        {
            ITimeSeriesEntryCursor cursor = CreateCursor();

            InsertAllDefaultEntries();

            cursor.SetToEnd();
            Assert.IsNull(cursor.Current);
            Assert.IsTrue(cursor.MovePrevious());
            Assert.IsNotNull(cursor.Current);

            // remember the entry and get its timestamp
            ITimeSeriesEntry timeSeriesEntry = cursor.Current;
            DateTime         timeStamp       = timeSeriesEntry.TimeStamp;

            // try to seek behind the end; will result in pointing to the last entry (see documentation of Seek(TimeStamp))
            Assert.IsTrue(cursor.Seek(timeStamp + new TimeSpan(100)));
            Assert.IsNotNull(cursor.Current);

            // check that we are indeed at the last entry
            Assert.IsTrue(TimeSeriesComparisons.CompareTimeSeriesEntry(timeSeriesEntry, cursor.Current));
        }