public async Task DocumentPartitionEndToEnd(IDocumentSerializer serializer) { var table = CloudStorageAccount.DevelopmentStorageAccount .CreateTableServiceClient() .GetTableClient(serializer.GetType().Name); await table.DeleteAsync(); await table.CreateAsync(); try { var repo = DocumentPartition.Create <DocumentEntity>(CloudStorageAccount.DevelopmentStorageAccount, table.Name, serializer: serializer); var partitionKey = "P" + Guid.NewGuid().ToString("N"); var rowKey = "R" + Guid.NewGuid().ToString("N"); var entity = await repo.PutAsync(new DocumentEntity { PartitionKey = partitionKey, RowKey = rowKey, Title = "Foo", }); entity.Title = "Bar"; await repo.PutAsync(entity); var saved = await repo.GetAsync(rowKey); Assert.NotNull(saved); Assert.Equal("Bar", saved !.Title); var entities = new List <DocumentEntity>(); await foreach (var e in repo.EnumerateAsync()) { entities.Add(e); } Assert.Single(entities); await repo.DeleteAsync(saved); Assert.Null(await repo.GetAsync(rowKey)); await foreach (var _ in repo.EnumerateAsync()) { Assert.False(true, "Did not expect to find any entities"); } } finally { await table.DeleteAsync(); } }
public async Task CanFilterDocuments() { var account = CloudStorageAccount.DevelopmentStorageAccount; await LoadBooksAsync(DocumentRepository.Create <Book>( account, nameof(CanFilterDocuments), x => x.Author, x => x.ISBN)); var repo = DocumentPartition.Create <Book>(account, nameof(CanFilterDocuments), "Rick Riordan", x => x.ISBN); //// Get specific set of books from one particular publisher/country combination //// in this case, 978-[English-speaking country, 1][Disney Editions, 4231] //// See https://en.wikipedia.org/wiki/List_of_group-1_ISBN_publisher_codes //var query = from book in repo.CreateQuery() // where // book.ISBN.CompareTo("97814231") >= 0 && // book.ISBN.CompareTo("97814232") < 0 // select new { book.ISBN, book.Title }; //var result = await query.AsAsyncEnumerable().ToListAsync(); //Assert.Equal(4, result.Count); }