Skip to content

Commit

Permalink
Improving Documentation and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
asketagarwal committed Feb 11, 2021
1 parent 2ac2b41 commit 0967b2b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Microsoft.Azure.Cosmos/src/CosmosClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public CosmosClient(
/// </summary>
/// <param name="accountEndpoint">The cosmos service endpoint to use</param>
/// <param name="authKeyOrResourceToken">The cosmos account key or resource token to use to create the client.</param>
/// <param name="containers">(Optional) Containers to be initialized</param>
/// <param name="containers">Containers to be initialized identified by it's database name and container name.</param>
/// <param name="cosmosClientOptions">(Optional) client options</param>
/// <param name="cancellationToken">(Optional) Cancellation Token</param>
/// <returns>
Expand Down Expand Up @@ -323,7 +323,7 @@ static async Task<CosmosClient> CreateAndInitializeAsync(string accountEndpoint,
/// <see href="https://docs.microsoft.com/azure/cosmos-db/performance-tips">performance guide</see>.
/// </summary>
/// <param name="connectionString">The connection string to the cosmos account. ex: https://mycosmosaccount.documents.azure.com:443/;AccountKey=SuperSecretKey; </param>
/// <param name="containers">(Optional) Containers to be initialized</param>
/// <param name="containers">Containers to be initialized identified by it's database name and container name.</param>
/// <param name="cosmosClientOptions">(Optional) client options</param>
/// <param name="cancellationToken">(Optional) Cancellation Token</param>
/// <returns>
Expand Down Expand Up @@ -376,7 +376,7 @@ static async Task<CosmosClient> CreateAndInitializeAsync(string connectionString
/// </summary>
/// <param name="accountEndpoint">The cosmos service endpoint to use.</param>
/// <param name="tokenCredential"><see cref="TokenCredential"/>The token to provide AAD token for authorization.</param>
/// <param name="containers">(Optional) Containers to be initialized</param>
/// <param name="containers">Containers to be initialized identified by it's database name and container name.</param>
/// <param name="cosmosClientOptions">(Optional) client options</param>
/// <param name="cancellationToken">(Optional) Cancellation Token</param>
/// <returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,15 @@ public async Task DatabaseIncorrectTest()
List<(string databaseId, string containerId)> containers = new List<(string databaseId, string containerId)>
{ ("IncorrectDatabase", "ClientCreateAndInitializeContainer")};
(string endpoint, string authKey) = TestCommon.GetAccountInfo();
CosmosClient cosmosClient = await CosmosClient.CreateAndInitializeAsync(endpoint, authKey, containers);
cosmosClient.Dispose();
try
{
CosmosClient cosmosClient = await CosmosClient.CreateAndInitializeAsync(endpoint, authKey, containers);
}
catch (CosmosException ex)
{
Assert.IsTrue(ex.StatusCode == HttpStatusCode.NotFound);
throw ex;
}
}

[TestMethod]
Expand All @@ -109,8 +116,15 @@ public async Task ContainerIncorrectTest()
List<(string databaseId, string containerId)> containers = new List<(string databaseId, string containerId)>
{ ("ClientCreateAndInitializeDatabase", "IncorrectContainer")};
(string endpoint, string authKey) = TestCommon.GetAccountInfo();
CosmosClient cosmosClient = await CosmosClient.CreateAndInitializeAsync(endpoint, authKey, containers);
cosmosClient.Dispose();
try
{
CosmosClient cosmosClient = await CosmosClient.CreateAndInitializeAsync(endpoint, authKey, containers);
}
catch (CosmosException ex)
{
Assert.IsTrue(ex.StatusCode == HttpStatusCode.NotFound);
throw ex;
}
}
}
}

0 comments on commit 0967b2b

Please sign in to comment.