예제 #1
0
        public void DefaultCosmosClientProviderCorrectlyDisposesOverload()
        {
            DefaultCosmosClientProvider provider =
                new DefaultCosmosClientProvider(
                    new Mock <ICosmosClientOptionsProvider>().Object,
                    Options.Create(new RepositoryOptions
            {
                CosmosConnectionString =
                    "AccountEndpoint=https://localtestcosmos.documents.azure.com:443/;AccountKey=RmFrZUtleQ==;"
            }));

            provider.Dispose();

            Assert.ThrowsAsync <ObjectDisposedException>(
                async() => await provider.UseClientAsync(client => client.ReadAccountAsync()));
        }
예제 #2
0
        public void DefaultCosmosClientProviderCorrectlyDisposesOverloadWithTokenCredential()
        {
            Mock <ICosmosClientOptionsProvider> mock = new Mock <ICosmosClientOptionsProvider>();

            mock.SetupGet(provider => provider.ClientOptions).Returns(new CosmosClientOptions());
            DefaultCosmosClientProvider provider =
                new DefaultCosmosClientProvider(
                    mock.Object,
                    Microsoft.Extensions.Options.Options.Create(new RepositoryOptions
            {
                TokenCredential = new TestTokenCredential(),
                AccountEndpoint = "https://localtestcosmos.documents.azure.com:443/"
            }));

            provider.Dispose();

            Assert.ThrowsAsync <ObjectDisposedException>(
                async() => await provider.UseClientAsync(client => client.ReadAccountAsync()));
        }