|
|
|
@ -19,21 +19,23 @@ namespace HttpClientStudy.UnitTest.ConfigTest
|
|
|
|
|
public void WebApiOption_Test()
|
|
|
|
|
{
|
|
|
|
|
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
|
|
|
|
|
configurationBuilder.AddWebApiConfigration();
|
|
|
|
|
configurationBuilder.AddWebApiConfiguration();
|
|
|
|
|
|
|
|
|
|
IConfiguration configuration = configurationBuilder.Build();
|
|
|
|
|
|
|
|
|
|
var services = new ServiceCollection();
|
|
|
|
|
services.AddSingleton<IConfiguration>(configuration);
|
|
|
|
|
services.AddSingleton(configuration);
|
|
|
|
|
services.AddWebApiOptions();
|
|
|
|
|
|
|
|
|
|
var provider = services.BuildServiceProvider();
|
|
|
|
|
IOptions<Config.WebApiConfig> webApiOptions = provider.GetService<IOptions<Config.WebApiConfig>>();
|
|
|
|
|
IOptions<WebApiConfig>? webApiOptions = provider.GetService<IOptions<WebApiConfig>>();
|
|
|
|
|
|
|
|
|
|
var webApiConfig = webApiOptions.Value;
|
|
|
|
|
var webApiConfig = webApiOptions?.Value;
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(webApiOptions);
|
|
|
|
|
Assert.NotNull(webApiConfig);
|
|
|
|
|
Assert.NotEmpty(webApiConfig.BaseUrl);
|
|
|
|
|
Assert.NotEmpty(webApiConfig.WebAppMutexName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
@ -46,6 +48,7 @@ namespace HttpClientStudy.UnitTest.ConfigTest
|
|
|
|
|
var webApiConfig = webApiMonitor.CurrentValue;
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(webApiConfig);
|
|
|
|
|
Assert.NotEmpty(webApiConfig.WebAppMutexName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|