Adding cursor size tests
This commit is contained in:
		| @@ -34,6 +34,10 @@ namespace Aurora.Cursor | ||||
|  | ||||
|         public CursorResult<T> GetNextPage() | ||||
|         { | ||||
|             if (this._pageSize < 0) | ||||
|             { | ||||
|                 throw new InvalidOperationException("Page Size must be greater than zero"); | ||||
|             } | ||||
|             List<KeyValuePair<string, T>> tmpList; | ||||
|  | ||||
|             // Sort reference list | ||||
| @@ -61,20 +65,14 @@ namespace Aurora.Cursor | ||||
|  | ||||
|             int endIdx = startIdx + this._pageSize; | ||||
|  | ||||
|             List<T> selection = new List<T>(); | ||||
|  | ||||
|             // Get page | ||||
|             for (int i = startIdx; i < tmpList.Count && i < endIdx; i++) | ||||
|             { | ||||
|                 selection.Add(tmpList.ElementAt(i).Value); | ||||
|             } | ||||
|             List<KeyValuePair<string, T>> selection = tmpList.GetRange(startIdx, this._pageSize > tmpList.Count ? tmpList.Count : this._pageSize); | ||||
|  | ||||
|             return new CursorResult<T> | ||||
|             { | ||||
|                 NextPageToken = selection[selection.Count - 1].Id, | ||||
|                 PrevPageToken = selection[0].Id, | ||||
|                 NextPageToken = selection[selection.Count - 1].Key, | ||||
|                 PrevPageToken = selection[0].Key, | ||||
|                 Count = this._list.Count, | ||||
|                 Result = selection | ||||
|                 Result = selection.ConvertAll(item => item.Value) | ||||
|             }; | ||||
|         } | ||||
|  | ||||
| @@ -83,13 +81,13 @@ namespace Aurora.Cursor | ||||
|             throw new NotImplementedException(); | ||||
|         } | ||||
|  | ||||
|         public Cursor<T> WithNextPage(string nextPageToken) | ||||
|         public Cursor<T> WithNextPageToken(string nextPageToken) | ||||
|         { | ||||
|             this._nextPageToken = nextPageToken; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Cursor<T> WithPreviousPage(string prevPageToken) | ||||
|         public Cursor<T> WithPreviousPageToken(string prevPageToken) | ||||
|         { | ||||
|             this._previousPageToken = prevPageToken; | ||||
|             return this; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user