Resolve all 46 low-severity architecture review findings
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests;
|
||||
|
||||
public class GlobalOptionsValidationTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("ScadaBridge:OpcUa:ApplicationName")]
|
||||
[InlineData("ScadaBridge:MxGateway:ClientNamePrefix")]
|
||||
public void StartupRejectsBlankIdentity(string key)
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddSingleton<IConfiguration>(new ConfigurationBuilder().AddInMemoryCollection(
|
||||
new Dictionary<string, string?> { [key] = " " }).Build());
|
||||
services.AddDataConnectionLayer();
|
||||
using var provider = services.BuildServiceProvider();
|
||||
var exception = Assert.Throws<OptionsValidationException>(() => provider.GetRequiredService<IStartupValidator>().Validate());
|
||||
Assert.Contains(key, exception.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DefaultsValidateAtStartup()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddSingleton<IConfiguration>(new ConfigurationBuilder().Build());
|
||||
services.AddDataConnectionLayer();
|
||||
using var provider = services.BuildServiceProvider();
|
||||
provider.GetRequiredService<IStartupValidator>().Validate();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user