Ejemplo n.º 1
0
        public void CppCheckError_MinimalErrorCanBeConvertedToSarifIssue()
        {
            Result result = new CppCheckError("id", "message", "verbose", "style", _dummyLocations)
                            .ToSarifIssue();

            Assert.Equal("id", result.RuleId);
            Assert.Equal("verbose", result.Message.Text);
            result.PropertyNames.Count.Should().Be(1);
            result.GetProperty("Severity").Should().Be("style");
            Assert.Equal("file.cpp", result.Locations.First().PhysicalLocation.ArtifactLocation.Uri.ToString());
        }
Ejemplo n.º 2
0
        public void CppCheckError_ErrorWithSingleLocationIsConvertedToSarifIssue()
        {
            Result result = new CppCheckError("id", "message", "verbose", "my fancy severity", ImmutableArray.Create(
                                                  new CppCheckLocation("foo.cpp", 1234)
                                                  )).ToSarifIssue();

            Assert.AreEqual("id", result.RuleId);
            Assert.AreEqual("verbose", result.Message);
            result.PropertyNames.Count.Should().Be(1);
            result.GetProperty("Severity").Should().Be("my fancy severity");
            result.Locations.SequenceEqual(new[] { new Location {
                                                       ResultFile = new PhysicalLocation
                                                       {
                                                           Uri    = new Uri("foo.cpp", UriKind.RelativeOrAbsolute),
                                                           Region = new Region {
                                                               StartLine = 1234
                                                           }
                                                       }
                                                   } }, Location.ValueComparer).Should().BeTrue();
            Assert.IsNull(result.CodeFlows);
        }
Ejemplo n.º 3
0
 public void CppCheckError_MinimalErrorCanBeConvertedToSarifIssue()
 {
     Result result = new CppCheckError("id", "message", "verbose", "style", _dummyLocations)
         .ToSarifIssue();
     Assert.AreEqual("id", result.RuleId);
     Assert.AreEqual("verbose", result.Message);
     result.PropertyNames.Count.Should().Be(1);
     result.GetProperty("Severity").Should().Be("style");
     Assert.AreEqual("file.cpp", result.Locations.First().ResultFile.Uri.ToString());
 }
Ejemplo n.º 4
0
 public void CppCheckError_ErrorWithSingleLocationIsConvertedToSarifIssue()
 {
     Result result = new CppCheckError("id", "message", "verbose", "my fancy severity", ImmutableArray.Create(
         new CppCheckLocation("foo.cpp", 1234)
         )).ToSarifIssue();
     Assert.AreEqual("id", result.RuleId);
     Assert.AreEqual("verbose", result.Message);
     result.PropertyNames.Count.Should().Be(1);
     result.GetProperty("Severity").Should().Be("my fancy severity");
     result.Locations.SequenceEqual(new[] { new Location {
             ResultFile = new PhysicalLocation
             {
                 Uri = new Uri("foo.cpp", UriKind.RelativeOrAbsolute),
                 Region = new Region { StartLine = 1234 }
             }
         }
     }, Location.ValueComparer).Should().BeTrue();
     Assert.IsNull(result.CodeFlows);
 }