private async Task CompositeIndexImplementation()
        {
            Cosmos.IndexingPolicy indexingPolicy = new Cosmos.IndexingPolicy()
            {
                Automatic     = true,
                IncludedPaths = new Collection <Cosmos.IncludedPath>()
                {
                    new  Cosmos.IncludedPath()
                    {
                        Path = DefaultPath,
                    }
                },
                ExcludedPaths    = new Collection <Cosmos.ExcludedPath>(),
                IndexingMode     = Cosmos.IndexingMode.Consistent,
                CompositeIndexes = new Collection <Collection <Cosmos.CompositePath> >()
                {
                    new Collection <Cosmos.CompositePath>()
                    {
                        new  Cosmos.CompositePath()
                        {
                            Path  = "/name",
                            Order = Cosmos.CompositePathSortOrder.Ascending
                        },
                        new  Cosmos.CompositePath()
                        {
                            Path  = "/age",
                            Order = Cosmos.CompositePathSortOrder.Descending
                        }
                    }
                }
            };

            await IndexingPolicyTests.RoundTripWithLocal(indexingPolicy);
        }
        private async Task SpatialBoundingBoxImplementation()
        {
            Cosmos.IndexingPolicy indexingPolicy = new Cosmos.IndexingPolicy()
            {
                Automatic     = true,
                IncludedPaths = new Collection <Cosmos.IncludedPath>()
                {
                    new  Cosmos.IncludedPath()
                    {
                        Path = DefaultPath,
                    }
                },
                ExcludedPaths  = new Collection <Cosmos.ExcludedPath>(),
                IndexingMode   = Cosmos.IndexingMode.Consistent,
                SpatialIndexes = new Collection <Cosmos.SpatialPath>()
                {
                    new Cosmos.SpatialPath
                    {
                        Path         = "/location/?",
                        SpatialTypes = new Collection <Cosmos.SpatialType>()
                        {
                            Cosmos.SpatialType.LineString,
                            Cosmos.SpatialType.MultiPolygon,
                            Cosmos.SpatialType.Point,
                            Cosmos.SpatialType.Polygon,
                        },
                        BoundingBox = new Cosmos.BoundingBoxProperties()
                        {
                            Xmin = 0,
                            Ymin = 0,
                            Xmax = 10,
                            Ymax = 10,
                        }
                    },
                    new Cosmos.SpatialPath
                    {
                        Path         = "/spatial/*",
                        SpatialTypes = new Collection <Cosmos.SpatialType>()
                        {
                            Cosmos.SpatialType.Point
                        },
                        BoundingBox = new Cosmos.BoundingBoxProperties()
                        {
                            Xmin = 0,
                            Ymin = 0,
                            Xmax = 10,
                            Ymax = 10,
                        }
                    }
                }
            };

            Cosmos.GeospatialConfig geospatialConfig = new Cosmos.GeospatialConfig();
            geospatialConfig.GeospatialType = Cosmos.GeospatialType.Geometry;
            await IndexingPolicyTests.RoundTripWithLocal(indexingPolicy, geospatialConfig);
        }
        private static object CreateTypeFromAssembly <T>(Assembly assembly, params object[] parameters)
        {
            Type   typeFromAssembly = IndexingPolicyTests.GetTypeFromAssembly(assembly, typeof(T).Name);
            object createdType      = Activator.CreateInstance(typeFromAssembly, parameters);

            if (createdType == null)
            {
                Assert.Fail($"Failed to construct type of {nameof(T)} from assembly:{assembly.GetName().Name} using parameters: {parameters}");
            }

            return(createdType);
        }
        public async Task DoubleRoundTrip()
        {
            await cosmosClient.Databases.CreateDatabaseIfNotExistsAsync(database.Id);

            Cosmos.IndexingPolicy   indexingPolicy          = IndexingPolicyTests.CreateDefaultIndexingPolicy();
            CosmosContainerSettings cosmosContainerSettings = new CosmosContainerSettings()
            {
                Id             = Guid.NewGuid().ToString(),
                IndexingPolicy = indexingPolicy,
            };

            await IndexingPolicyTests.RoundTripWithLocal(indexingPolicy);
        }
Exemplo n.º 5
0
        public async Task DoubleRoundTrip()
        {
            await IndexingPolicyTests.documentClient.CreateDatabaseIfNotExistsAsync(IndexingPolicyTests.database);

            IndexingPolicy     indexingPolicy             = IndexingPolicyTests.CreateDefaultIndexingPolicy();
            DocumentCollection documentCollectionToCreate = new DocumentCollection()
            {
                Id             = Guid.NewGuid().ToString(),
                IndexingPolicy = indexingPolicy,
            };

            await IndexingPolicyTests.RoundTripWithLocal(indexingPolicy);
        }
        public async Task ExcludeAll()
        {
            Cosmos.IndexingPolicy indexingPolicy = IndexingPolicyTests.CreateDefaultIndexingPolicy();
            indexingPolicy.IncludedPaths = new Collection <Cosmos.IncludedPath>();
            indexingPolicy.ExcludedPaths = new Collection <Cosmos.ExcludedPath>()
            {
                new Cosmos.ExcludedPath()
                {
                    Path = "/*",
                }
            };

            await IndexingPolicyTests.RoundTripWithLocal(indexingPolicy);
        }
        private static async Task <dynamic> CreateDocumentClientFromAssembly(Assembly assembly)
        {
            // Define parameters for class constructor 'DocumentClient(Uri serviceEndpoint, string authKeyOrResourceToken)'
            object[] documentClientConstructorParameters = new object[]
            {
                new Uri(ConfigurationManager.AppSettings["GatewayEndpoint"]),
                ConfigurationManager.AppSettings["MasterKey"],
                null,
                null
            };

            dynamic documentClient = IndexingPolicyTests.CreateTypeFromAssembly <DocumentClient>(assembly, documentClientConstructorParameters);
            await documentClient.OpenAsync();

            return(documentClient);
        }
        public async Task SpatialIndex()
        {
            Cosmos.IndexingPolicy indexingPolicy = IndexingPolicyTests.CreateDefaultIndexingPolicy();
            indexingPolicy.IncludedPaths = new Collection <Cosmos.IncludedPath>()
            {
                new Cosmos.IncludedPath()
                {
                    Path    = DefaultPath,
                    Indexes = new Collection <Cosmos.Index>()
                    {
                        new Cosmos.SpatialIndex(Cosmos.DataType.Point),
                    }
                }
            };

            await IndexingPolicyTests.RoundTripWithLocal(indexingPolicy);
        }
        public async Task HashRange()
        {
            Cosmos.IndexingPolicy indexingPolicy = IndexingPolicyTests.CreateDefaultIndexingPolicy();
            indexingPolicy.IncludedPaths = new Collection <Cosmos.IncludedPath>()
            {
                new Cosmos.IncludedPath()
                {
                    Path    = DefaultPath,
                    Indexes = new Collection <Cosmos.Index>()
                    {
                        new Cosmos.HashIndex(Cosmos.DataType.Number, 3),
                        new Cosmos.RangeIndex(Cosmos.DataType.String, -1),
                    }
                }
            };

            await IndexingPolicyTests.RoundTripWithLocal(indexingPolicy);
        }
Exemplo n.º 10
0
        public async Task GeoFencingIndex()
        {
            IndexingPolicy indexingPolicy = IndexingPolicyTests.CreateDefaultIndexingPolicy();

            indexingPolicy.IncludedPaths = new Collection <IncludedPath>()
            {
                new IncludedPath()
                {
                    Path    = DefaultPath,
                    Indexes = new Collection <Index>()
                    {
                        new SpatialIndex(DataType.LineString),
                        new SpatialIndex(DataType.Point),
                        new SpatialIndex(DataType.Polygon),
                    }
                }
            };

            await IndexingPolicyTests.RoundTripWithLocal(indexingPolicy);
        }
Exemplo n.º 11
0
        public async Task ExcludedPaths()
        {
            IndexingPolicy indexingPolicy = IndexingPolicyTests.CreateDefaultIndexingPolicy();

            indexingPolicy.IncludedPaths = new Collection <IncludedPath>()
            {
                new IncludedPath()
                {
                    Path = "/*",
                }
            };
            indexingPolicy.ExcludedPaths = new Collection <ExcludedPath>()
            {
                new ExcludedPath()
                {
                    Path = "/nonIndexedContent/*",
                }
            };

            await IndexingPolicyTests.RoundTripWithLocal(indexingPolicy);
        }
Exemplo n.º 12
0
        public async Task CompositeIndex()
        {
            IndexingPolicy indexingPolicy = new IndexingPolicy()
            {
                Automatic     = true,
                Type          = IndexPolicyType.Range,
                IncludedPaths = new Collection <IncludedPath>()
                {
                    new IncludedPath()
                    {
                        Path = DefaultPath,
                    }
                },
                ExcludedPaths     = new Collection <ExcludedPath>(),
                IndexingMode      = IndexingMode.Consistent,
                AdditionalIndexes = new AdditionalIndexes()
                {
                    Composite = new Collection <Collection <CompositePath> >()
                    {
                        new Collection <CompositePath>()
                        {
                            new CompositePath()
                            {
                                Path  = "/name",
                                Order = CompositePathSortOrder.Ascending
                            },
                            new CompositePath()
                            {
                                Path  = "/age",
                                Order = CompositePathSortOrder.Descending
                            }
                        }
                    }
                }
            };

            await IndexingPolicyTests.RoundTripWithLocal(indexingPolicy);
        }
        private static IndexingPolicy GetIndexingPolicyFromAssembly(Assembly assembly, object indexingPolicy)
        {
            Type indexingPolicyType = IndexingPolicyTests.GetTypeFromAssembly(assembly, "IndexingPolicy");

            return(JsonConvert.DeserializeObject <IndexingPolicy>(JsonConvert.SerializeObject(indexingPolicy, indexingPolicyType, null)));
        }
 public async Task DefaultIndexingPolicy()
 {
     Cosmos.IndexingPolicy indexingPolicy = IndexingPolicyTests.CreateDefaultIndexingPolicy();
     await IndexingPolicyTests.RoundTripWithLocal(indexingPolicy);
 }
Exemplo n.º 15
0
 public void TestInitialize()
 {
     // Put test init code here
     IndexingPolicyTests.Cleanup().Wait();
 }
Exemplo n.º 16
0
 public void TestCleanup()
 {
     IndexingPolicyTests.Cleanup().Wait();
 }