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())); }
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())); }