public static string GetNewIssueLink(string link, IssueInformation issueInfo)
        {
            IIssueFormatter formatter = null;

            switch (issueInfo.IssueType)
            {
            case IssueType.NoFailure:
                formatter = new NoFailuresIssueFormatter(issueInfo);
                break;

            case IssueType.SingleFailure:
                formatter = new SingleFailureIssueFormatter(issueInfo);
                break;

            default:
                return(string.Empty);
            }

            string FormattedURL = string.Format(CultureInfo.InvariantCulture, Properties.Resources.FormattedLink,
                                                link,
                                                formatter.GetFormattedTitle(),
                                                formatter.GetFormattedBody());
            string escapedURL = Uri.EscapeUriString(FormattedURL).Replace("#", "%23");

            return(escapedURL);
        }
예제 #2
0
        public void IssueFormattingTest()
        {
            string           link = "https://github.com/bla/bla-blas";
            IssueInformation singleFailureIssue = new IssueInformation(null, "glimpse", null,
                                                                       new Uri("https://www.helpUri.com"), "ruleSource", "ruleDescription",
                                                                       "testMessages", null, null,
                                                                       "elementPath", null, null,
                                                                       "processName", IssueType.SingleFailure, null);

            IssueInformation noFailureIssue = new IssueInformation(null, "glimpse", null,
                                                                   new Uri("https://www.helpUri.com"), "ruleSource", "ruleDescription",
                                                                   "testMessages", null, null,
                                                                   "elementPath", null, null,
                                                                   "processName", IssueType.NoFailure, null);

            IIssueFormatter singleIssueFormatter = new SingleFailureIssueFormatter(singleFailureIssue);
            IIssueFormatter noIssueFormatter     = new NoFailuresIssueFormatter(noFailureIssue);

            string singleFailureLinkActual   = IssueFormatterFactory.GetNewIssueLink(link, singleFailureIssue);
            string singleFailureLinkExpected = GetLink(link, singleIssueFormatter);
            string noFailureLinkActual       = IssueFormatterFactory.GetNewIssueLink(link, noFailureIssue);
            string noFailureLinkExpected     = GetLink(link, noIssueFormatter);

            Assert.AreEqual(singleFailureLinkExpected, singleFailureLinkActual);
            Assert.AreEqual(noFailureLinkExpected, noFailureLinkActual);
            Assert.AreNotEqual(singleFailureLinkExpected, noFailureLinkActual);
            Assert.AreNotEqual(noFailureLinkExpected, singleFailureLinkActual);
        }