Beispiel #1
0
        public async Task CanBrowseToAdvancedPageWithSharding()
        {
            var ms           = new MemoryStream();
            var streamWriter = new StreamWriter(ms);
            var expected     = new string('a', 1024);

            streamWriter.Write(expected);
            streamWriter.Flush();
            ms.Position = 0;

            await shardedClient.UploadAsync("a.txt", ms);

            await shardedClient.UploadAsync("b.txt", ms);

            await shardedClient.UploadAsync("c.txt", ms);

            await shardedClient.UploadAsync("d.txt", ms);

            await shardedClient.UploadAsync("e.txt", ms);

            var pagingInfo = new ShardPagingInfo(shardedClient.NumberOfShards)
            {
                CurrentPage = 2
            };
            var result = await shardedClient.BrowseAsync(2, pagingInfo);

            Assert.Equal(1, result.Length);

            pagingInfo.CurrentPage++;
            result = await shardedClient.BrowseAsync(2, pagingInfo);

            Assert.Equal(0, result.Length);
        }
Beispiel #2
0
        public async Task CanNotBrowseToPageFarAway()
        {
            var ms           = new MemoryStream();
            var streamWriter = new StreamWriter(ms);
            var expected     = new string('a', 1024);

            streamWriter.Write(expected);
            streamWriter.Flush();
            ms.Position = 0;

            await shardedClient.UploadAsync("a.txt", ms);

            ms.Position = 0;
            await shardedClient.UploadAsync("b.txt", ms);

            ms.Position = 0;
            await shardedClient.UploadAsync("c.txt", ms);

            ms.Position = 0;
            await shardedClient.UploadAsync("d.txt", ms);

            ms.Position = 0;
            await shardedClient.UploadAsync("e.txt", ms);

            ms.Position = 0;

            var pagingInfo = new ShardPagingInfo(shardedClient.NumberOfShards)
            {
                CurrentPage = 20
            };

            try
            {
                await shardedClient.BrowseAsync(2, pagingInfo);

                Assert.Equal(true, false);//Should not get here
            }
            catch (Exception exception)
            {
                Assert.IsType <InvalidOperationException>(exception);
            }
        }