I am trying to create a series of tests against an Asp.net core service. The service starts perfect as well as the tests running against it. The problem is when I try to start the tests using webHostBuilder. At the time of making the request I get the error:
System.AggregateException: One or more errors occurred. (String reference not set to an instance of a String. Parameter name: s)
From the startUp class of the service
StartUp - >
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using TrackerBackend.Core.Middleware;
namespace serviceName
{
public class Startup
{
public Startup(IConfiguration configuration, IHostingEnvironment env)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddApplicationInsightsTelemetry();
services.AddMvc();
Ioc.AddRegistration(services, Configuration);
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseAuthentication();
app.UseMvc();
}
}
}
That's how I'm creating the client - >
public Client()
{
_server = new TestServer(new WebHostBuilder().UseStartup<Startup>());
_client = _server.CreateClient();
_client.BaseAddress = new Uri("http://localhost:58255");
}
I hope you can help me. Thanks