Skip to content

Instantly share code, notes, and snippets.

@ManfredLange
Created September 26, 2021 02:20
Show Gist options
  • Save ManfredLange/23f0d1131d0944528e62785d9f5ba75f to your computer and use it in GitHub Desktop.
Save ManfredLange/23f0d1131d0944528e62785d9f5ba75f to your computer and use it in GitHub Desktop.
namespace CosmosDbTest
{
public class CosmosDbTests
{
[OneTimeTearDown]
public void OneTimeTearDown()
{
//Dispose of CosmosClient
_cosmosClient.Dispose(); // Move this to teardown of fixture
}
// ... other code left out for brevity ...
[Test]
public async Task CosmosDemo()
{
await GetStartedDemoAsync().ConfigureAwait(false);
}
/// <summary>
/// Entry point to call methods that operate on Azure Cosmos DB resources in this sample
/// </summary>
private async Task GetStartedDemoAsync()
{
// Create a new instance of the Cosmos Client
_cosmosClient = new CosmosClient(EndpointUri, PrimaryKey, new CosmosClientOptions() { ApplicationName = "CosmosDBDotnetQuickstart" });
await CreateDatabaseAsync().ConfigureAwait(false);
await CreateContainerAsync().ConfigureAwait(false);
await ScaleContainerAsync().ConfigureAwait(false);
await AddItemsToContainerAsync().ConfigureAwait(false);
await QueryItemsAsync().ConfigureAwait(false);
await ReplaceFamilyItemAsync().ConfigureAwait(false);
await DeleteFamilyItemAsync().ConfigureAwait(false);
await DeleteDatabaseAndCleanupAsync().ConfigureAwait(false);
}
// ... other code left out for brevity
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment