private static void VerifyErrorListItemEntry(SarifErrorListItem error, SarifResultTableEntry entry, dynamic test) { error.ShortMessage.Should().Be(test.ShortMessage); error.Message.Should().Be(test.FullMessage); error.RawMessage.Should().Be(test.RawMessage.Trim()); error.HasEmbeddedLinks.Should().Be(test.ContainsHyperlink); entry.TryGetValue(StandardTableKeyNames.Text, out object textColumn).Should().BeTrue(); entry.TryGetValue(StandardTableKeyNames.FullText, out object fullTextColumn).Should().BeTrue(); entry.TryGetValue(StandardTableKeyNames2.TextInlines, out object textInlinesColumn).Should().BeTrue(); entry.TryGetValue(SarifResultTableEntry.FullTextInlinesColumnName, out object fullTextInlinesColumn).Should().BeTrue(); ((string)textColumn).Should().Be(test.ShortMessage); ((string)fullTextColumn).Should().Be(error.HasDetailsContent ? test.FullMessage : null); if (test.ContainsHyperlink) { var textInlines = textInlinesColumn as List <Inline>; textInlines.Should().NotBeNull(); SdkUIUtilities.GetPlainText(textInlines).Should().Be(test.ShortPlainText); var fullTextInlines = fullTextInlinesColumn as List <Inline>; fullTextInlines.Should().NotBeNull(); SdkUIUtilities.GetPlainText(fullTextInlines).Should().Be(test.FullPlainText); } else { textInlinesColumn.Should().BeNull(); fullTextInlinesColumn.Should().BeNull(); } }
public void GetPlainText_ConvertInlinesWithTwoHttpLinks() { // raw text "The quick [brown fox](https://example.com) jumps over the [lazy dog](1)."; const string url = "http://example.com"; const string expected = @"The quick brown fox jumps over the lazy dog."; var hyperlink1 = new Hyperlink(new Run("brown fox")); hyperlink1.NavigateUri = new Uri(url); var hyperlink2 = new Hyperlink(new Run("lazy dog")); hyperlink2.Tag = 1; var inputs = new List <Inline> { new Run("The quick "), hyperlink1, new Run(" jumps over the "), hyperlink2, new Run("."), }; string actual = SdkUIUtilities.GetPlainText(inputs); actual.Should().NotBeNull(); actual.Should().Be(expected); }
public void GetPlainText_GetNullIfInputIsNullOrEmpty() { List <Inline> inputs = null; string actual = SdkUIUtilities.GetPlainText(inputs); actual.Should().BeNull(); inputs = new List <Inline>(); actual = SdkUIUtilities.GetPlainText(inputs); actual.Should().BeNull(); }
public void GetPlainText_ConvertInlinesWithPathLink() { // raw text "The quick brown fox jumps over the lazy dog." const string expected = @"The quick brown fox jumps over the lazy dog."; var inputs = new List <Inline> { new Run("The quick "), new Run("brown fox"), new Run(" jumps over the "), new Run("lazy dog."), }; string actual = SdkUIUtilities.GetPlainText(inputs); actual.Should().NotBeNull(); actual.Should().Be(expected); }
public void GetPlainText_ConvertInlinesWithLiteralBrackets() { // raw text "The file ['..\directory\file.cpp']({url}) has a \[problem\]." const string expected = @"The file '..\directory\file.cpp' has a \[problem\]."; var hyperlink = new Hyperlink(new Run(@"'..\directory\file.cpp'")); hyperlink.NavigateUri = new Uri("file://*****:*****@" has a \[problem\]."), }; string actual = SdkUIUtilities.GetPlainText(inputs); actual.Should().NotBeNull(); actual.Should().Be(expected); }