I have written a few xUnit tests for API controller methods. I am using the configuration setting from the azure portal app settings.
This is the code I used for initializing the settings.
private readonly IConfiguration _configuration;
public Controller(IConfiguration configuration)
{
_configuration = configuration;
}
In the test case class,
IConfiguration _configuration;
[Fact]
public async void Method1()
{
Controller controller = new Controller(_configuration);
}
After run the test I am getting an error
System.NullReferenceException : Object reference not set to an instance of an object.
What is the possible solution for this?