I'm new to asp.net core. Currently I'm developing a small site that uses authentication providers from Google, Facebook and Microsoft.
Now I wanted to write some integration tests for my HomeController.
This is how my test class looks like:
public class HomeControllerTests : IDisposable
{
private HomeController _homeController;
private readonly TestServer _server;
private readonly HttpClient _client;
public HomeControllerTests()
{
_server = new TestServer(new WebHostBuilder().UseEnvironment("Development").UseStartup<Startup>());
_client = _server.CreateClient();
}
[Fact]
public async void Test()
{
var result = await _client.GetAsync("/");
Assert.NotNull(result);
}
public void Dispose()
{
_server.Dispose();
_client.Dispose();
}
}
Now in my Startup.cs at
builder.AddUserSecrets();
an InvalidOperationException gets thrown:
An exception of type 'System.InvalidOperationException' occurred in Microsoft.Extensions.Configuration.UserSecrets.dll but was not handled in user code.
Can anybody point me to the right direction what could be wrong? Will the tests run on the build server as well?