public async Task should_load_incrementally_from_an_existing_storage() { var storage = new MemoryStorage(); await Task.WhenAll(Enumerable.Range(0, 8).Select(x => storage.Put(new TestStorageObject(x)))); var collection = new StorageCollection<TestStorageObject>(storage, "0", "6"); Assert.True(collection.HasMoreItems); Assert.Equal(0, collection.Count); await collection.LoadMoreItemsAsync(2); Assert.Equal(2, collection.Count); Assert.Equal(collection.Select(e => e.Id), Enumerable.Range(0, 2).Select(i => i.ToString())); await collection.LoadMoreItemsAsync(2); Assert.Equal(4, collection.Count); Assert.Equal(collection.Select(e => e.Id), Enumerable.Range(0, 4).Select(i => i.ToString())); Assert.False(collection.IsLoading); Assert.True(collection.HasMoreItems); await collection.LoadMoreItemsAsync(10); Assert.Equal(6, collection.Count); Assert.False(collection.HasMoreItems); Assert.Equal(collection.Select(e => e.Id), Enumerable.Range(0, 6).Select(i => i.ToString())); }
public async Task should_load_all_items() { var storage = new MemoryStorage(); await Task.WhenAll(Enumerable.Range(0, 8).Select(x => storage.Put(new TestStorageObject(x)))); var collection = new StorageCollection<TestStorageObject>(storage, "0", "6"); Assert.True(collection.HasMoreItems); Assert.Equal(0, collection.Count); await collection.LoadAllAsync(2); Assert.Equal(6, collection.Count); Assert.False(collection.HasMoreItems); Assert.Equal(collection.Select(e => e.Id), Enumerable.Range(0, 6).Select(i => i.ToString())); }