Closed felipe-rodrigues closed 1 year ago
Use the container's provided HTTP client (it is pre-configured to trust the CosmosDb Emulator's certificate):
Thank you @HofmeisterAn.
I'm using efcore to connect with the database. There is one configuration on the setup I needed to do. but it was very close wit your solution.
/// _container = new CosmosDbBuilder().Build();
var options = new DbContextOptionsBuilder<MyContext>()
.UseCosmos(connection, databaseName: "test", (options) =>
{
options.HttpClientFactory(() => _container..HttpClient);
options.RequestTimeout(TimeSpan.FromSeconds(5));
options.ConnectionMode(Microsoft.Azure.Cosmos.ConnectionMode.Gateway);
})
.Options;
services.AddSingleton(sp => options);
services.AddScoped<MyContext>();
Testcontainers version
3.2.0
Using the latest Testcontainers version?
Yes
Host OS
Windows
Host arch
x64
.NET version
6.0.2
Docker version
Docker info
What happened?
I'm trying to create tests for an application that uses CosmosDb with EntityFramework Core.
I'm getting:
Relevant log output
No response
Additional information
EfCore Context
TestClass: