Skip to content

Commit

Permalink
#595 Create a separate property for the known issue link
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryKolinchuk committed Jul 28, 2021
1 parent 499988f commit 312f02d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ namespace SIM.Sitecore9Installer.Tests.Validation.Validators
{
public class PrerequisitesDownloadLinksValidatorTests
{
private const string KnownIssueMessage = "{0}: the '{1}' parameter contains the following invalid link that is not accessible:\n\n{2}\n\nThis behavior looks to be related to the following known issue:\n\nhttps://github.com/Sitecore/Sitecore-Instance-Manager/wiki/Known-Issue-Outdated-Download-Link-to-Microsoft-Web-Platform-Installer\n\nPlease try to apply the solution mentioned there.";
private const string KnownIssueMessage = "{0}: the '{1}' parameter contains the following invalid link that is not accessible:\n\n{2}\n\nThis behavior looks to be related to the following known issue:\n\n{3}\n\nPlease try to apply the solution mentioned there.";

private const string InvalidLinkMessage = "{0}: the '{1}' parameter contains the following invalid link that is not accessible:\n\n{2}\n\nThis behavior may occur due to similar symptoms described in the following known issue:\n\nhttps://github.com/Sitecore/Sitecore-Instance-Manager/wiki/Known-Issue-Outdated-Download-Link-to-Microsoft-Web-Platform-Installer";
private const string InvalidLinkMessage = "{0}: the '{1}' parameter contains the following invalid link that is not accessible:\n\n{2}\n\nThis behavior may occur due to similar symptoms described in the following known issue:\n\n{3}";

private const string InvalidValueMessage = "{0}: the '{1}' parameter contains the following invalid value:\n\n{2}\n\nIt should contain download link that starts with '{3}'.";

Expand Down Expand Up @@ -50,14 +50,21 @@ public void EvaluateTests(string taskName, string paramName, string paramValue,

// Assert
Assert.Equal(warnings.Count(), warningsCount);
this.ValidateMessage(warnings, message, taskName, paramName, paramValue, string.Join("' or '", paramValuePrefixes));
if (message == KnownIssueMessage || message == InvalidLinkMessage)
{
this.ValidateMessage(warnings, message, taskName, paramName, paramValue, validator.KnownIssueLink);
}
else
{
this.ValidateMessage(warnings, message, taskName, paramName, paramValue, string.Join("' or '", paramValuePrefixes));
}
}

private void ValidateMessage(IEnumerable<ValidationResult> warnings, string message, string taskName, string paramName, string paramValue, string paramValuePrefixes)
private void ValidateMessage(IEnumerable<ValidationResult> warnings, string message, string taskName, string paramName, string paramValue, string paramChangeable)
{
if (!string.IsNullOrEmpty(message))
{
message = string.Format(message, taskName, paramName, paramValue, paramValuePrefixes);
message = string.Format(message, taskName, paramName, paramValue, paramChangeable);
Assert.Contains(warnings, warning => warning.Message.Equals(message));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class PrerequisitesDownloadLinksValidator : BaseValidator
// parameter to validate the following known issue: https://github.com/Sitecore/Sitecore-Instance-Manager/wiki/Known-Issue-Outdated-Download-Link-to-Microsoft-Web-Platform-Installer
public virtual string WebPlatformDownload => "WebPlatformDownload";

public virtual string KnownIssueLink => "https://github.com/Sitecore/Sitecore-Instance-Manager/wiki/Known-Issue-Outdated-Download-Link-to-Microsoft-Web-Platform-Installer";

protected override IEnumerable<ValidationResult> GetErrorsForTask(Task task, IEnumerable<InstallParam> paramsToValidate)
{
string paramNamePostfix = string.Empty;
Expand Down Expand Up @@ -42,13 +44,13 @@ protected override IEnumerable<ValidationResult> GetErrorsForTask(Task task, IEn
if (installParam.Name == this.WebPlatformDownload)
{
yield return new ValidationResult(ValidatorState.Warning,
$"{TaskName}: the '{installParam.Name}' parameter contains the following invalid link that is not accessible:\n\n{installParam.Value}\n\nThis behavior looks to be related to the following known issue:\n\nhttps://github.com/Sitecore/Sitecore-Instance-Manager/wiki/Known-Issue-Outdated-Download-Link-to-Microsoft-Web-Platform-Installer\n\nPlease try to apply the solution mentioned there.",
$"{TaskName}: the '{installParam.Name}' parameter contains the following invalid link that is not accessible:\n\n{installParam.Value}\n\nThis behavior looks to be related to the following known issue:\n\n{KnownIssueLink}\n\nPlease try to apply the solution mentioned there.",
null);
}
else
{
yield return new ValidationResult(ValidatorState.Warning,
$"{TaskName}: the '{installParam.Name}' parameter contains the following invalid link that is not accessible:\n\n{installParam.Value}\n\nThis behavior may occur due to similar symptoms described in the following known issue:\n\nhttps://github.com/Sitecore/Sitecore-Instance-Manager/wiki/Known-Issue-Outdated-Download-Link-to-Microsoft-Web-Platform-Installer",
$"{TaskName}: the '{installParam.Name}' parameter contains the following invalid link that is not accessible:\n\n{installParam.Value}\n\nThis behavior may occur due to similar symptoms described in the following known issue:\n\n{KnownIssueLink}",
null);
}
}
Expand Down

0 comments on commit 312f02d

Please sign in to comment.