コード例 #1
0
 private void VerifyGremlinGraphCreation(GremlinGraph gremlinGraph, GremlinGraphCreateUpdateParameters gremlinGraphCreateUpdateParameters)
 {
     Assert.AreEqual(gremlinGraph.Resource.Id, gremlinGraphCreateUpdateParameters.Resource.Id);
     Assert.AreEqual(gremlinGraph.Resource.IndexingPolicy.IndexingMode.Value.ToString().ToLower(), gremlinGraphCreateUpdateParameters.Resource.IndexingPolicy.IndexingMode.Value.ToString().ToLower());
     Assert.AreEqual(gremlinGraph.Resource.PartitionKey.Kind, gremlinGraphCreateUpdateParameters.Resource.PartitionKey.Kind);
     Assert.AreEqual(gremlinGraph.Resource.PartitionKey.Paths, gremlinGraphCreateUpdateParameters.Resource.PartitionKey.Paths);
     Assert.AreEqual(gremlinGraph.Resource.DefaultTtl, gremlinGraphCreateUpdateParameters.Resource.DefaultTtl);
 }
コード例 #2
0
        public async Task GremlinGraphListTests()
        {
            List <GremlinGraph> gremlinGraphs = await CosmosDBManagementClient.GremlinResources.ListGremlinGraphsAsync(resourceGroupName, databaseAccountName, databaseName).ToEnumerableAsync();

            Assert.NotNull(gremlinGraphs);
            Assert.AreEqual(gremlinGraphs.Count, 1);
            GremlinGraph gremlinGraph = await CosmosDBManagementClient.GremlinResources.GetGremlinGraphAsync(resourceGroupName, databaseAccountName, databaseName, gremlinGraphName);

            VerifyEqualGremlinGraphs(gremlinGraphs[0], gremlinGraph);
        }
コード例 #3
0
        private void VerifyEqualGremlinGraphs(GremlinGraph expectedValue, GremlinGraph actualValue)
        {
            Assert.AreEqual(expectedValue.Id, actualValue.Id);
            Assert.AreEqual(expectedValue.Name, actualValue.Name);
            Assert.AreEqual(expectedValue.Location, actualValue.Location);
            Assert.AreEqual(expectedValue.Tags, actualValue.Tags);
            Assert.AreEqual(expectedValue.Type, actualValue.Type);

            Assert.AreEqual(expectedValue.Options, actualValue.Options);

            Assert.AreEqual(expectedValue.Resource.Id, actualValue.Resource.Id);
            Assert.AreEqual(expectedValue.Resource.Rid, actualValue.Resource.Rid);
            Assert.AreEqual(expectedValue.Resource.Ts, actualValue.Resource.Ts);
            Assert.AreEqual(expectedValue.Resource.Etag, actualValue.Resource.Etag);

            Assert.AreEqual(expectedValue.Resource.ConflictResolutionPolicy.ConflictResolutionPath, actualValue.Resource.ConflictResolutionPolicy.ConflictResolutionPath);
            Assert.AreEqual(expectedValue.Resource.ConflictResolutionPolicy.ConflictResolutionPath, actualValue.Resource.ConflictResolutionPolicy.ConflictResolutionPath);
            Assert.AreEqual(expectedValue.Resource.ConflictResolutionPolicy.Mode, actualValue.Resource.ConflictResolutionPolicy.Mode);

            Assert.AreEqual(expectedValue.Resource.DefaultTtl, actualValue.Resource.DefaultTtl);

            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.Automatic, actualValue.Resource.IndexingPolicy.Automatic);

            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.IncludedPaths.Count, actualValue.Resource.IndexingPolicy.IncludedPaths.Count);
            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.IncludedPaths[0].Path, actualValue.Resource.IndexingPolicy.IncludedPaths[0].Path);
            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.IncludedPaths[0].Indexes, actualValue.Resource.IndexingPolicy.IncludedPaths[0].Indexes);

            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.ExcludedPaths.Count, actualValue.Resource.IndexingPolicy.ExcludedPaths.Count);
            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.ExcludedPaths[0].Path, actualValue.Resource.IndexingPolicy.ExcludedPaths[0].Path);

            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.CompositeIndexes.Count, actualValue.Resource.IndexingPolicy.CompositeIndexes.Count);
            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.CompositeIndexes[0].Count, actualValue.Resource.IndexingPolicy.CompositeIndexes[0].Count);
            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.CompositeIndexes[0][0].Path, actualValue.Resource.IndexingPolicy.CompositeIndexes[0][0].Path);
            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.CompositeIndexes[0][0].Order, actualValue.Resource.IndexingPolicy.CompositeIndexes[0][0].Order);
            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.CompositeIndexes[0][1].Path, actualValue.Resource.IndexingPolicy.CompositeIndexes[0][1].Path);
            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.CompositeIndexes[0][1].Order, actualValue.Resource.IndexingPolicy.CompositeIndexes[0][1].Order);
            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.CompositeIndexes[1].Count, actualValue.Resource.IndexingPolicy.CompositeIndexes[1].Count);
            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.CompositeIndexes[1][0].Path, actualValue.Resource.IndexingPolicy.CompositeIndexes[1][0].Path);
            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.CompositeIndexes[1][0].Order, actualValue.Resource.IndexingPolicy.CompositeIndexes[1][0].Order);
            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.CompositeIndexes[1][1].Path, actualValue.Resource.IndexingPolicy.CompositeIndexes[1][1].Path);
            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.CompositeIndexes[1][1].Order, actualValue.Resource.IndexingPolicy.CompositeIndexes[1][1].Order);

            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.IndexingMode, actualValue.Resource.IndexingPolicy.IndexingMode);

            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.SpatialIndexes.Count, actualValue.Resource.IndexingPolicy.SpatialIndexes.Count);
            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.SpatialIndexes[0].Path, actualValue.Resource.IndexingPolicy.SpatialIndexes[0].Path);
            Assert.AreEqual(expectedValue.Resource.IndexingPolicy.SpatialIndexes[0].Types, actualValue.Resource.IndexingPolicy.SpatialIndexes[0].Types);

            Assert.AreEqual(expectedValue.Resource.PartitionKey.Kind, actualValue.Resource.PartitionKey.Kind);
            Assert.AreEqual(expectedValue.Resource.PartitionKey.Paths, actualValue.Resource.PartitionKey.Paths);
            Assert.AreEqual(expectedValue.Resource.PartitionKey.Version, actualValue.Resource.PartitionKey.Version);

            Assert.AreEqual(expectedValue.Resource.UniqueKeyPolicy.UniqueKeys.Count, actualValue.Resource.UniqueKeyPolicy.UniqueKeys.Count);
            Assert.AreEqual(expectedValue.Resource.UniqueKeyPolicy.UniqueKeys[0].Paths, actualValue.Resource.UniqueKeyPolicy.UniqueKeys[0].Paths);
        }
コード例 #4
0
        public async Task GremlinGraphCreateUpdateTests()
        {
            IList <IncludedPath> includedPath = new List <IncludedPath> {
                new IncludedPath {
                    Path = "/*"
                }
            };
            IList <ExcludedPath> excludedPaths = new List <ExcludedPath> {
                new ExcludedPath {
                    Path = "/pathToNotIndex/*"
                }
            };
            IList <IList <CompositePath> > compositeIndexes = new List <IList <CompositePath> >
            {
                new List <CompositePath>
                {
                    new CompositePath {
                        Path = "/orderByPath1", Order = CompositePathSortOrder.Ascending
                    },
                    new CompositePath {
                        Path = "/orderByPath2", Order = CompositePathSortOrder.Descending
                    }
                },
                new List <CompositePath>
                {
                    new CompositePath {
                        Path = "/orderByPath3", Order = CompositePathSortOrder.Ascending
                    },
                    new CompositePath {
                        Path = "/orderByPath4", Order = CompositePathSortOrder.Descending
                    }
                }
            };
            IList <SpatialSpec> spatialIndexes = new List <SpatialSpec> {
                new SpatialSpec("/*", new List <SpatialType> {
                    new SpatialType("Point")
                })
            };

            IndexingPolicy indexingPolicy = new IndexingPolicy(true, IndexingMode.Consistent, includedPath, excludedPaths, compositeIndexes, spatialIndexes);

            ContainerPartitionKey containerPartitionKey = new ContainerPartitionKey(new List <string> {
                "/address"
            }, "Hash", null);
            IList <string> paths = new List <string>()
            {
                "/testpath"
            };
            UniqueKey         uk         = new UniqueKey(paths);
            IList <UniqueKey> uniqueKeys = new List <UniqueKey>();

            uniqueKeys.Add(uk);
            UniqueKeyPolicy uniqueKeyPolicy = new UniqueKeyPolicy(uniqueKeys);

            ConflictResolutionPolicy conflictResolutionPolicy = new ConflictResolutionPolicy(new ConflictResolutionMode("LastWriterWins"), "/path", "");
            CreateUpdateOptions      createUpdateOptions      = new CreateUpdateOptions(sampleThroughput, new AutoscaleSettings());

            GremlinGraphCreateUpdateParameters gremlinGraphCreateUpdateParameters = new GremlinGraphCreateUpdateParameters(new GremlinGraphResource(gremlinGraphName, indexingPolicy, containerPartitionKey, -1, uniqueKeyPolicy, conflictResolutionPolicy), createUpdateOptions);

            Response <GremlinGraph> gremlinResponse = await WaitForCompletionAsync(await CosmosDBManagementClient.GremlinResources.StartCreateUpdateGremlinGraphAsync(resourceGroupName, databaseAccountName, databaseName, gremlinGraphName, gremlinGraphCreateUpdateParameters));

            Assert.NotNull(gremlinResponse);
            GremlinGraph gremlinGraph = gremlinResponse.Value;

            Assert.NotNull(gremlinGraph);

            VerifyGremlinGraphCreation(gremlinGraph, gremlinGraphCreateUpdateParameters);

            var throughputResponse = CosmosDBManagementClient.GremlinResources.GetGremlinGraphThroughputAsync(resourceGroupName, databaseAccountName, databaseName, gremlinGraphName);
            ThroughputSettingsData ThroughputSettingsData = throughputResponse.ConfigureAwait(false).GetAwaiter().GetResult();

            Assert.NotNull(throughputSettings);
            Assert.NotNull(throughputSettings.Name);
            Assert.AreEqual(throughputSettings.Resource.Throughput, sampleThroughput);
            Assert.AreEqual(gremlinGraphsThroughputType, throughputSettings.Type);

            CreateUpdateOptions createUpdateOptions2 = new CreateUpdateOptions(sampleThroughput2, new AutoscaleSettings());
            GremlinGraphCreateUpdateParameters gremlinGraphCreateUpdateParameters2 = new GremlinGraphCreateUpdateParameters(new GremlinGraphResource(gremlinGraphName, indexingPolicy, containerPartitionKey, -1, uniqueKeyPolicy, conflictResolutionPolicy), createUpdateOptions2);

            Response <GremlinGraph> gremlinResponse2 = await WaitForCompletionAsync(await CosmosDBManagementClient.GremlinResources.StartCreateUpdateGremlinGraphAsync(resourceGroupName, databaseAccountName, databaseName, gremlinGraphName, gremlinGraphCreateUpdateParameters2));

            Assert.NotNull(gremlinResponse2);
            GremlinGraph gremlinGraph2 = gremlinResponse2.Value;

            Assert.NotNull(gremlinGraph2);

            VerifyGremlinGraphCreation(gremlinGraph2, gremlinGraphCreateUpdateParameters2);

            var throughputResponse2 = CosmosDBManagementClient.GremlinResources.GetGremlinGraphThroughputAsync(resourceGroupName, databaseAccountName, databaseName, gremlinGraphName);
            ThroughputSettingsData throughputSettings2 = throughputResponse2.ConfigureAwait(false).GetAwaiter().GetResult();

            Assert.NotNull(throughputSettings2);
            Assert.NotNull(throughputSettings2.Name);
            Assert.AreEqual(throughputSettings2.Resource.Throughput, sampleThroughput2);
            Assert.AreEqual(gremlinGraphsThroughputType, throughputSettings2.Type);
        }