using ZB.MOM.WW.ScadaBridge.CLI.Commands;
namespace ZB.MOM.WW.ScadaBridge.CLI.Tests;
///
/// Regression tests for URL validation: a malformed --url previously reached
/// new Uri(...) in the constructor
/// and threw an unhandled .
///
public class UrlValidationTests
{
/// Verifies that absolute HTTP and HTTPS URLs are accepted as management URLs.
/// The candidate management URL.
[Theory]
[InlineData("http://localhost:9001")]
[InlineData("https://central-host:5000/")]
[InlineData("http://central")]
public void IsValidManagementUrl_AcceptsAbsoluteHttpUrls(string url)
{
Assert.True(CommandHelpers.IsValidManagementUrl(url));
}
/// Verifies that malformed or non-HTTP URLs are rejected as management URLs.
/// The candidate management URL.
[Theory]
[InlineData("localhost:9001")] // no scheme
[InlineData("")] // empty
[InlineData(" ")] // whitespace
[InlineData("not a url")]
[InlineData("ftp://central:21")] // non-http scheme
public void IsValidManagementUrl_RejectsMalformedOrNonHttpUrls(string url)
{
Assert.False(CommandHelpers.IsValidManagementUrl(url));
}
}