예제 #1
0
        public void ThenTheTenantCalledShouldContainCosmosConfigurationForACosmosContainerDefinitionWithDatabaseNameAndContainerName(
            string tenantName,
            string databaseName,
            string containerName)
        {
            InMemoryTenantProvider tenantProvider =
                ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <InMemoryTenantProvider>();

            ITenant tenant = tenantProvider.GetTenantByName(tenantName)
                             ?? throw new TenantNotFoundException($"Could not find tenant with name '{tenantName}'");

            var containerDefinition = new CosmosContainerDefinition(databaseName, containerName, null);

            CosmosConfiguration tenantConfigItem = tenant.GetCosmosConfiguration(containerDefinition);

            // GetCosmosStorageConfiguration would have thrown an exception if the config didn't exist, but we'll do a
            // not null assertion anyway...
            Assert.IsNotNull(tenantConfigItem);
        }
예제 #2
0
        public void ThenTheTenantCalledShouldNotContainCosmosConfigurationForACosmosContainerDefinitionWithDatabaseNameAndContainerName(
            string tenantName,
            string databaseName,
            string containerName)
        {
            InMemoryTenantProvider tenantProvider =
                ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <InMemoryTenantProvider>();

            ITenant enrolledTenant = tenantProvider.GetTenantByName(tenantName)
                                     ?? throw new TenantNotFoundException($"Could not find tenant with name '{tenantName}'");

            var containerDefinition = new CosmosContainerDefinition(databaseName, containerName, null);

            try
            {
                // This should throw. If it doesn't, then the config exists and the test fails.
                enrolledTenant.GetCosmosConfiguration(containerDefinition);
                Assert.Fail($"Did not expect to find Cosmos configuration in tenant '{tenantName}' for container definition with database name '{databaseName}' and container name '{containerName}', but it was present.");
            }
            catch (ArgumentException)
            {
                // This is what's expected - all is well.
            }
        }