private async Task CompareConsistency() { var random = new Random((int)DateTime.Now.Ticks); var doc = new SampleDocument { prop1 = Guid.NewGuid().ToString(), prop2 = random.Next(100), prop3 = Guid.NewGuid().ToString(), prop4 = random.Next(100), prop5 = DateTime.UtcNow.ToLongTimeString(), prop6 = random.Next(100), prop7 = Guid.NewGuid().ToString(), prop8 = random.Next(100), prop9 = Guid.NewGuid().ToString(), prop10 = random.Next(100), prop11 = Guid.NewGuid().ToString(), prop12 = random.Next(100), prop13 = Guid.NewGuid().ToString(), prop14 = random.Next(100), prop15 = Guid.NewGuid().ToString(), prop16 = random.Next(100) }; //doc.Id = Guid.NewGuid().ToString(); //var strongWriteResults = await this.CreateSampleDocument(database, collection, doc, ConsistencyLevel.Strong); //var strongReadResults = await this.ReadSampleDocument(strongWriteResults.Resource.Id, ConsistencyLevel.Strong); doc.Id = Guid.NewGuid().ToString(); var boundedWriteResults = await this.CreateSampleDocument(database, collection, doc, ConsistencyLevel.BoundedStaleness); var boundedReadResults = await this.ReadSampleDocument(boundedWriteResults.Resource.Id, ConsistencyLevel.BoundedStaleness); doc.Id = Guid.NewGuid().ToString(); var sessionWriteResults = await this.CreateSampleDocument(database, collection, doc, ConsistencyLevel.Session); var sessionReadResults = await this.ReadSampleDocument(sessionWriteResults.Resource.Id, ConsistencyLevel.Session); doc.Id = Guid.NewGuid().ToString(); var eventualWriteResults = await this.CreateSampleDocument(database, collection, doc, ConsistencyLevel.Eventual); var eventualReadResults = await this.ReadSampleDocument(eventualWriteResults.Resource.Id, ConsistencyLevel.Eventual); //PrintDetails(strongWriteResults, "Strong write"); PrintDetails(boundedWriteResults, "Bounded write"); PrintDetails(sessionWriteResults, "Session write"); PrintDetails(eventualWriteResults, "Eventual write"); //PrintDetails(strongReadResults, "Strong read"); PrintDetails(boundedReadResults, "Bounded read"); PrintDetails(sessionReadResults, "Session read"); PrintDetails(eventualReadResults, "Eventual read"); }
private async Task <ResourceResponse <Document> > CreateSampleDocument(string databaseName, string collectionName, SampleDocument sample, ConsistencyLevel level) { var options = new RequestOptions() { ConsistencyLevel = level }; var result = await this.client.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), sample, options); return(result); }