38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using ZB.MOM.WW.ScadaBridge.Commons.Validation;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Validation;
|
|
|
|
public class GrpcEndpointRulesTests
|
|
{
|
|
[Theory]
|
|
[InlineData("scadabridge-site-a-node-a")]
|
|
[InlineData("site-a-node-a:8083")]
|
|
[InlineData("ftp://x:1")]
|
|
public void TryValidate_RejectsNonHttpEndpoints(string value)
|
|
{
|
|
Assert.False(GrpcEndpointRules.TryValidate(value, false, out var error));
|
|
Assert.NotNull(error);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("http://site-a-node-a:8083")]
|
|
[InlineData("https://h")]
|
|
public void TryValidate_AcceptsHttpEndpoints(string value)
|
|
{
|
|
Assert.True(GrpcEndpointRules.TryValidate(value, false, out var error));
|
|
Assert.Null(error);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null)]
|
|
[InlineData("")]
|
|
[InlineData(" ")]
|
|
public void TryValidate_EmptyHonoursAllowEmpty(string? value)
|
|
{
|
|
Assert.True(GrpcEndpointRules.TryValidate(value, true, out var ok));
|
|
Assert.Null(ok);
|
|
Assert.False(GrpcEndpointRules.TryValidate(value, false, out var err));
|
|
Assert.NotNull(err);
|
|
}
|
|
}
|