Exemplo n.º 1
0
        private void TestAllDataSourceTypes(Action <SearchServiceClient, DataSource> testMethod)
        {
            SearchServiceClient searchClient = Data.GetSearchServiceClient();

            var deletionDetectionPolicy = new SoftDeleteColumnDeletionDetectionPolicy("isDeleted", "1");
            var changeDetectionPolicy   = new HighWaterMarkChangeDetectionPolicy("fakecolumn");

            // Test all combinations of data source types and configurations.

            // AzureSql
            testMethod(searchClient, CreateTestSqlDataSource());
            testMethod(searchClient, CreateTestSqlDataSource(deletionDetectionPolicy));
            testMethod(searchClient, CreateTestSqlDataSource(new SqlIntegratedChangeTrackingPolicy()));
            testMethod(searchClient, CreateTestSqlDataSource(changeDetectionPolicy, deletionDetectionPolicy));

            // SQL on VM
            testMethod(searchClient, CreateTestSqlDataSource(useSqlVm: true));
            testMethod(searchClient, CreateTestSqlDataSource(deletionDetectionPolicy, useSqlVm: true));
            testMethod(searchClient, CreateTestSqlDataSource(new SqlIntegratedChangeTrackingPolicy(), useSqlVm: true));
            testMethod(searchClient, CreateTestSqlDataSource(changeDetectionPolicy, deletionDetectionPolicy, useSqlVm: true));

            // CosmosDB
            testMethod(searchClient, CreateTestCosmosDbDataSource());
            testMethod(searchClient, CreateTestCosmosDbDataSource(useChangeDetection: true));
            testMethod(searchClient, CreateTestCosmosDbDataSource(deletionDetectionPolicy));
            testMethod(searchClient, CreateTestCosmosDbDataSource(deletionDetectionPolicy, useChangeDetection: true));

            // Azure Blob Storage
            testMethod(searchClient, CreateTestBlobDataSource());
            testMethod(searchClient, CreateTestBlobDataSource(deletionDetectionPolicy));

            // Azure Table Storage
            testMethod(searchClient, CreateTestTableDataSource());
            testMethod(searchClient, CreateTestTableDataSource(deletionDetectionPolicy));
        }
        private async Task CreateDataSourceAsync()
        {
            var dataContainer             = new DataContainer("Package", null);
            var dataSourceCredentials     = new DataSourceCredentials(GetCosmosDBConnectionString());
            var dataChangeDetectionPolicy = new HighWaterMarkChangeDetectionPolicy("_ts");

            var dataDeletionDetectionPolicy = new SoftDeleteColumnDeletionDetectionPolicy("IsDeleted", true);

            var dataSource = new DataSource(
                DATASOURCE_NAME,
                DataSourceType.DocumentDb,
                dataSourceCredentials,
                dataContainer, "Strikes CosmosDB Settings",
                dataChangeDetectionPolicy,
                dataDeletionDetectionPolicy);

            await _client.DataSources.CreateOrUpdateWithHttpMessagesAsync(dataSource);
        }
Exemplo n.º 3
0
        private static void AssertDataDeletionDetectionPoliciesEqual(DataDeletionDetectionPolicy expected, DataDeletionDetectionPolicy actual)
        {
            if (expected == null)
            {
                Assert.Null(actual);
                return;
            }

            Assert.NotNull(actual);

            SoftDeleteColumnDeletionDetectionPolicy expectedSoftDelete = expected as SoftDeleteColumnDeletionDetectionPolicy;

            if (expectedSoftDelete != null)
            {
                SoftDeleteColumnDeletionDetectionPolicy actualSoftDelete = Assert.IsType <SoftDeleteColumnDeletionDetectionPolicy>(actual);
                Assert.Equal(expectedSoftDelete.SoftDeleteColumnName, actualSoftDelete.SoftDeleteColumnName);
                Assert.Equal(expectedSoftDelete.SoftDeleteMarkerValue, actualSoftDelete.SoftDeleteMarkerValue);
                return;
            }

            Assert.False(true, "Unexpected type of deletion detection policy (did you forget to add support for a new policy type to test code?):" + expected.GetType().Name);
        }