I am new to asp.net core. I am currently developing a small site that uses authentication providers from Google, Facebook and Microsoft.
Now I wanted to write some integration tests for mine HomeController.
This is what 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 on
builder.AddUserSecrets();
throws an InvalidOperationException:
An exception of type "System.InvalidOperationException" occurred in Microsoft.Extensions.Configuration.UserSecrets.dll, but was not processed in the user code.
Can someone point me in the right direction, what could be wrong? Will tests run on the build server?