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 virtual void TestSetAfterFromAfterEnd() { ITimeSeriesEntryCursor cursor = CreateCursor(); InsertAllDefaultEntries(); cursor.SetAfter(DefaultTimeSeries.TimeInterval.EndTime.AddTicks(1)); Assert.IsNull(cursor.Current); Assert.IsTrue(cursor.MovePrevious()); Assert.AreEqual(DefaultTimeSeries.TimeInterval.EndTime, cursor.Current.TimeStamp); cursor.SetAfter(DateTimeHelper.UtcMaxValue); Assert.IsNull(cursor.Current); Assert.IsTrue(cursor.MovePrevious()); Assert.AreEqual(DefaultTimeSeries.TimeInterval.EndTime, cursor.Current.TimeStamp); }
public void TestSetToEndAtMaxValue() { InsertDefaultEntryByTimeStamp(MaximumTimeStamp); ITimeSeriesEntryCursor cursor = CreateCursor(); cursor.SetToEnd(); Assert.IsNull(cursor.Current); Assert.IsTrue(cursor.MovePrevious()); CheckEntry(cursor.Current); }
public virtual void TestSetAfter() { ITimeSeriesEntryCursor cursor = CreateCursor(); InsertAllDefaultEntries(); foreach (long timeStamp in DefaultTimeStamps) { cursor.SetAfter(DateTimeHelper.ToDateTime(timeStamp)); Assert.IsTrue(cursor.MovePrevious()); Assert.AreEqual(timeStamp, DateTimeHelper.ToLong(cursor.Current.TimeStamp)); cursor.SetAfter(DateTimeHelper.ToDateTime(timeStamp + 1)); Assert.IsTrue(cursor.MovePrevious()); Assert.AreEqual(timeStamp, DateTimeHelper.ToLong(cursor.Current.TimeStamp)); cursor.SetAfter(DateTimeHelper.ToDateTime(timeStamp - 1)); Assert.AreEqual(timeStamp, DateTimeHelper.ToLong(cursor.Current.TimeStamp)); } }
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 TestWalkingMilesBeforeBegin() { ITimeSeriesEntryCursor cursor = CreateCursor(); InsertDefaultEntryByIndex(0); cursor.SetToStart(); Assert.IsNull(cursor.Current); // you cannot reach a valid entry before the beginning for (int i = 1; i < 20; ++i) { Assert.IsFalse(cursor.MovePrevious()); } // one step must be enough to get to the first entry Assert.IsTrue(cursor.MoveNext()); Assert.IsNotNull(cursor.Current); }
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)); }