public WhenDocumentsAreCreatedWithClassNameAsThePartitionKey() { //Given var collectionName = nameof(WhenDocumentsAreCreatedWithClassNameAsThePartitionKey); var docDbCollectionSettings = DocDbCollectionSettings.Create(collectionName, DocDbCollectionSettings.PartitionKeyTypeEnum.ClassName); this.testHarness = TestHarnessFunctions.GetDocumentDbTestHarness(collectionName, docDbCollectionSettings); //When for (var i = 0; i < 5; i++) { var car = new Car { id = Guid.NewGuid(), Make = "Saab" }; this.testHarness.DataStore.Create(car).Wait(); } this.testHarness.DataStore.CommitChanges().Wait(); //HACK: runtime manual override docDbCollectionSettings.EnableCrossParitionQueries = false; }
public WhenDocumentsAreCreatedWithIdAsThePartitionKey() { //Given var collectionName = nameof(WhenDocumentsAreCreatedWithIdAsThePartitionKey); this.docDbCollectionSettings = DocDbCollectionSettings.Create(collectionName, DocDbCollectionSettings.PartitionKeyTypeEnum.Id); this.testHarness = TestHarnessFunctions.GetDocumentDbTestHarness(collectionName, this.docDbCollectionSettings); //When for (var i = 0; i < 3; i++) //only three because they are expensive { var car = new Car { id = Guid.NewGuid(), Make = "Volvo" }; this.testHarness.DataStore.Create(car).Wait(); } this.testHarness.DataStore.CommitChanges().Wait(); }
internal static ITestHarness GetDocumentDbTestHarness(string testName, DocDbCollectionSettings collectionSettings = null) { var options = TestHarnessOptions.Create(collectionSettings ?? DocDbCollectionSettings.Create(testName)); var documentdbsettingsJson = "DocumentDbSettings.json"; /* * Create this file in your DataStore.Tests project root and set it's build output to "copy always" * This file should always be .gitignore(d), don't want to expose this in your repo. * { * "AuthorizationKey": "<azurekey>", * "DatabaseName": "<dbname>", * "EndpointUrl": "<endpointurl>" * } */ var location = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, documentdbsettingsJson); var documentDbSettings = JsonConvert.DeserializeObject <DocumentDbSettings>(File.ReadAllText(location)); documentDbSettings.CollectionSettings = options.CollectionSettings; return(DocumentDbTestHarness.Create(documentDbSettings)); }