I am writing unit tests for my .Net Core 5 web application. In the Startup.cs, I have 4 different calls similar to the following:
services.Configure<ServicesSettings>(Configuration.GetSection("ServicesSettings"));
each injecting a different class. I have tried the following:
ServicesSettings _serviceSettings = services.BuildServiceProvider().GetService<ServicesSettings>();
Assert.NotNull(_serviceSettings);
but it returns null. I am surprised that I could not find a similar question. I tried to look at ServiceCollection, but could not find a method.