You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I start any test I get this exception:
System.InvalidOperationException : Test application could not be initialized. You may need to create a custom mock for one of your registered services. If you are having difficulties debugging this error, open an issue at https://github.com/ivaylokenov/MyTested.AspNetCore.Mvc/issues. Provide your Startup classes and this exception message: 'Cloud name must be specified in Account!'
I have configured a Cloudinary Account in my StartUp and it gets the Account, ApiKey and ApiSecret from the appsettings.json. When debugging the cloudinary account is not configured and it throws the above exception. If I put the values of the Account, ApiKey and ApiSecret in the StartUp class it runs fine. How can I create a mock of this?
I tried this:
public class TestStartUp : Startup
{
public TestStartUp(IConfiguration configuration)
: base(configuration)
{
}
public void ConfigureTestServices(IServiceCollection services)
{
var cloud = "my cloud";
var apiKey = "my key";
var apiSecret = "my secret";
var cloudinaryAccount = new Account(cloud, apiKey, apiSecret);
var cloudinary = new Cloudinary(cloudinaryAccount);
services.ReplaceSingleton<Cloudinary>(cloudinary);
base.ConfigureServices(services);
}
}
But it does not work. I tried also using a CloudinaryMock.Instance but the result was the same.
The text was updated successfully, but these errors were encountered:
You are replacing the Cloudinary service and then calling the original ones, therefore the replacement is no longer valid. You first need to register everything from your base Startup and then replace:
@AchoVasilev Most probably your TestStartup is not located because of namespace/assembly name difference. If you could upload a sample from your solution, I may take a look.
When I start any test I get this exception:
System.InvalidOperationException : Test application could not be initialized. You may need to create a custom mock for one of your registered services. If you are having difficulties debugging this error, open an issue at https://github.com/ivaylokenov/MyTested.AspNetCore.Mvc/issues. Provide your Startup classes and this exception message: 'Cloud name must be specified in Account!'
I have configured a Cloudinary Account in my StartUp and it gets the Account, ApiKey and ApiSecret from the appsettings.json. When debugging the cloudinary account is not configured and it throws the above exception. If I put the values of the Account, ApiKey and ApiSecret in the StartUp class it runs fine. How can I create a mock of this?
I tried this:
public class TestStartUp : Startup
{
public TestStartUp(IConfiguration configuration)
: base(configuration)
{
}
But it does not work. I tried also using a CloudinaryMock.Instance but the result was the same.
The text was updated successfully, but these errors were encountered: