Problem
In my test setup, I need to get the ComsmosDb container's AccountEndpoint and AccountKey properties to configure my services.
CosmosDbContainer exposes the connection string that contains these properties. But it would be more convenient to have those properties directly exposed rather than having to parse the connection string
|
public string GetConnectionString() |
|
{ |
|
var properties = new Dictionary<string, string>(); |
|
properties.Add("AccountEndpoint", new UriBuilder(Uri.UriSchemeHttp, Hostname, GetMappedPublicPort(CosmosDbBuilder.CosmosDbPort)).ToString()); |
|
properties.Add("AccountKey", CosmosDbBuilder.DefaultAccountKey); |
|
return string.Join(";", properties.Select(property => string.Join("=", property.Key, property.Value))); |
|
} |
Solution
Add getters or get methods to return both AccountEndpoint and AccountKey and rewrite GetConnectionString to use those getters.
Benefit
Getting the properties in a more convenient way, while keeping the CosmosDbContainer class easy to read and maintain.
Alternatives
Get them by parsing the connection string as done today.
Would you like to help contributing this enhancement?
Yes
Problem
In my test setup, I need to get the ComsmosDb container's
AccountEndpointandAccountKeyproperties to configure my services.CosmosDbContainerexposes the connection string that contains these properties. But it would be more convenient to have those properties directly exposed rather than having to parse the connection stringtestcontainers-dotnet/src/Testcontainers.CosmosDb/CosmosDbContainer.cs
Lines 20 to 26 in 638a926
Solution
Add getters or get methods to return both
AccountEndpointandAccountKeyand rewriteGetConnectionStringto use those getters.Benefit
Getting the properties in a more convenient way, while keeping the
CosmosDbContainerclass easy to read and maintain.Alternatives
Get them by parsing the connection string as done today.
Would you like to help contributing this enhancement?
Yes