public bool TestIsValidConfiguration(string filePath) { try { BuildConfigurationType buildConfig = DeserializeBuildConfigInternal(filePath); if (buildConfig == null) { _logger?.LogError($"The provided configuration {filePath} is empty."); return(false); } string versionMatch = ConfigurationUtility.IsVersionMatch(buildConfig.ConfigVersion, Version) ? "[MATCH]" : "[MISSMATCH]"; string msg = $"{versionMatch} The provided configuration {filePath} is a valid configuration file." + $"\n\tConfiguration version:\t{buildConfig.ConfigVersion}" + $"\n\tParser version: \t{Version}"; // [gruenwaldlu, 2020-07-14-14:14:39+2]: Required for user feedback. Depending on the configuration, the logger may not print to the console out. Console.Out.Write(msg); _logger?.LogInformation(msg); return(true); } catch (Exception e) { StringBuilder builder = new StringBuilder(); string msg = BuildErrorMessage(builder, e); // [gruenwaldlu, 2020-07-27-13:45:55+2]: Required for user feedback. Depending on the configuration, the logger may not print to the console out. Console.Out.Write(msg); _logger?.LogWarning(msg); return(false); } }
public void Test__IsVersionMatch__ReturnsExpected(string semVer, ConfigVersion version, bool expected) { bool actual = ConfigurationUtility.IsVersionMatch(semVer, version); Assert.AreEqual(expected, actual); }