static private GetDefaultProblemBuilder ( ) : |
||
Результат |
public void AndroidStudioConverter_ConvertSarifResult_GeneratesLocationWithMethodEntryPointAndPackage() { AndroidStudioProblem.Builder builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = null; builder.Package = "FancyPackageName"; builder.Module = null; builder.EntryPointType = "method"; builder.EntryPointName = "my_method"; var expectedLocation = new Location { LogicalLocation = new LogicalLocation { FullyQualifiedName = "FancyPackageName\\my_method", Index = 1 } }; var expectedLogicalLocations = new List <LogicalLocation> { new LogicalLocation { ParentIndex = -1, FullyQualifiedName = "FancyPackageName", Kind = LogicalLocationKind.Package }, new LogicalLocation { ParentIndex = 0, Name = "my_method", FullyQualifiedName = @"FancyPackageName\my_method", Kind = LogicalLocationKind.Member } }; var converter = new AndroidStudioConverter(); Result result = converter.ConvertProblemToSarifResult(new AndroidStudioProblem(builder)); result.Locations[0].ValueEquals(expectedLocation).Should().BeTrue(); ValidateLogicalLocations(expectedLogicalLocations, converter.LogicalLocations); }
public void AndroidStudioConverter_ConvertSarifResult_RecordsModuleAsTopLevelIfPresent() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = null; builder.Module = "my_fancy_binary"; builder.EntryPointType = "method"; builder.EntryPointName = "my_method"; var expectedLocation = new Location { LogicalLocation = new LogicalLocation { FullyQualifiedName = "my_fancy_binary\\my_method", Index = 1 } }; var expectedLogicalLocations = new List <LogicalLocation> { new LogicalLocation { ParentIndex = -1, FullyQualifiedName = "my_fancy_binary", Kind = LogicalLocationKind.Module }, new LogicalLocation { ParentIndex = 0, Name = "my_method", FullyQualifiedName = @"my_fancy_binary\my_method", Kind = LogicalLocationKind.Member } }; var converter = new AndroidStudioConverter(); Result result = converter.ConvertProblemToSarifResult(new AndroidStudioProblem(builder)); result.Locations[0].ValueEquals(expectedLocation).Should().BeTrue(); ValidateLogicalLocations(expectedLogicalLocations, converter.LogicalLocations); }
public void AndroidStudioConverter_ConvertSarifResult_GeneratesLocationWithOnlyPackage() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = null; builder.Package = "FancyPackageName"; builder.Module = null; builder.EntryPointName = null; var expectedLocation = new Location { FullyQualifiedLogicalName = "FancyPackageName" }; var expectedLogicalLocations = new Dictionary <string, LogicalLocation> { { "FancyPackageName", new LogicalLocation { ParentKey = null, Kind = LogicalLocationKind.Package } } }; var converter = new AndroidStudioConverter(); Result result = converter.ConvertProblemToSarifResult(new AndroidStudioProblem(builder)); result.Locations[0].ValueEquals(expectedLocation).Should().BeTrue(); foreach (string key in expectedLogicalLocations.Keys) { expectedLogicalLocations[key].ValueEquals(converter.LogicalLocationsDictionary[key]).Should().BeTrue(); } converter.LogicalLocationsDictionary.Count.Should().Be(expectedLogicalLocations.Count); }
public void AndroidStudioConverter_ConvertSarifIssue_GeneratesLocationWithMethodEntryPointAndPackage() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = null; builder.Package = "FancyPackageName"; builder.Module = null; builder.EntryPointType = "method"; builder.EntryPointName = "my_method"; Assert.AreEqual(new Location { FullyQualifiedLogicalName = "FancyPackageName\\my_method", LogicalLocation = new[] { new LogicalLocationComponent { Name = "FancyPackageName", Kind = LogicalLocationKind.JvmPackage }, new LogicalLocationComponent { Name = "my_method", Kind = LogicalLocationKind.JvmFunction } } }, GetLocationForBuilder(builder)); }
public void AndroidStudioConverter_ConvertSarifIssue_CanRecordSourceFileAndModule() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = "File Goes Here"; builder.Package = null; builder.Module = "LastResortModule"; builder.EntryPointName = null; Assert.AreEqual(new Location { ResultFile = new PhysicalLocation { Uri = new Uri("File Goes Here", UriKind.RelativeOrAbsolute), }, FullyQualifiedLogicalName = "LastResortModule", LogicalLocation = new[] { new LogicalLocationComponent { Name = "LastResortModule", Kind = LogicalLocationKind.AndroidModule } } }, GetLocationForBuilder(builder)); }
public void AndroidStudioConverter_ConvertSarifIssue_RecordsModuleAsTopLevelIfPresent() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = null; builder.Module = "my_fancy_binary"; builder.EntryPointType = "method"; builder.EntryPointName = "my_method"; Assert.AreEqual( new Location { FullyQualifiedLogicalName = "my_fancy_binary\\my_method", LogicalLocation = new[] { new LogicalLocationComponent { Name = "my_fancy_binary", Kind = LogicalLocationKind.AndroidModule }, new LogicalLocationComponent { Name = "my_method", Kind = LogicalLocationKind.JvmFunction } } } , GetLocationForBuilder(builder)); }
public void AndroidStudioConverter_ConvertSarifResult_RecordsModuleAsTopLevelIfPresent() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = null; builder.Module = "my_fancy_binary"; builder.EntryPointType = "method"; builder.EntryPointName = "my_method"; var expectedLocation = new Location { FullyQualifiedLogicalName = "my_fancy_binary\\my_method", }; var expectedLogicalLocationComponents = new[] { new LogicalLocationComponent { Name = "my_fancy_binary", Kind = LogicalLocationKind.Module }, new LogicalLocationComponent { Name = "my_method", Kind = LogicalLocationKind.Member } }; LocationInfo locationInfo = GetLocationInfoForBuilder(builder); locationInfo.Location.Should().Be(expectedLocation); locationInfo.LogicalLocationComponents.SequenceEqual(expectedLogicalLocationComponents).Should().BeTrue(); }
public void AndroidStudioConverter_ConvertSarifResult_GeneratesLocationWithOnlyPackage() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = null; builder.Package = "FancyPackageName"; builder.Module = null; builder.EntryPointName = null; var expectedLocation = new Location { FullyQualifiedLogicalName = "FancyPackageName" }; var expectedLogicalLocationComponents = new[] { new LogicalLocationComponent { Name = "FancyPackageName", Kind = LogicalLocationKind.Package } }; LocationInfo locationInfo = GetLocationInfoForBuilder(builder); locationInfo.Location.Should().Be(expectedLocation); locationInfo.LogicalLocationComponents.SequenceEqual(expectedLogicalLocationComponents).Should().BeTrue(); }
public void AndroidStudioConverter_ConvertSarifResult_GeneratesLocationWithOnlyPackage() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = null; builder.Package = "FancyPackageName"; builder.Module = null; builder.EntryPointName = null; var expectedLocation = new Location { LogicalLocation = new LogicalLocation { FullyQualifiedName = "FancyPackageName", Index = 0 } }; var expectedLogicalLocations = new List <LogicalLocation> { new LogicalLocation { Kind = LogicalLocationKind.Package, FullyQualifiedName = "FancyPackageName" } }; var converter = new AndroidStudioConverter(); Result result = converter.ConvertProblemToSarifResult(new AndroidStudioProblem(builder)); result.Locations[0].ValueEquals(expectedLocation).Should().BeTrue(); ValidateLogicalLocations(expectedLogicalLocations, converter.LogicalLocations); }
public void AndroidStudioConverter_ConvertSarifResult_CanRecordSourceFileAndModule() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = "File Goes Here"; builder.Package = null; builder.Module = "LastResortModule"; builder.EntryPointName = null; var expectedLocation = new Location { ResultFile = new PhysicalLocation { Uri = new Uri("File Goes Here", UriKind.RelativeOrAbsolute), }, FullyQualifiedLogicalName = "LastResortModule" }; var expectedLogicalLocationComponents = new[] { new LogicalLocationComponent { Name = "LastResortModule", Kind = LogicalLocationKind.Module } }; LocationInfo locationInfo = GetLocationInfoForBuilder(builder); locationInfo.Location.Should().Be(expectedLocation); locationInfo.LogicalLocationComponents.SequenceEqual(expectedLogicalLocationComponents).Should().BeTrue(); }
public void AndroidStudioConverter_ConvertSarifResult_RemovesProjectDirPrefix() { AndroidStudioProblem.Builder builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = "file://$PROJECT_DIR$/mydir/myfile.xml"; LocationInfo locationInfo = GetLocationInfoForBuilder(builder); locationInfo.Location.PhysicalLocation.ArtifactLocation.Uri.ToString().Should().Be("mydir/myfile.xml"); }
public void AndroidStudioConverter_ConvertSarifResult_PersistsSourceLineInfo() { AndroidStudioProblem.Builder builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.Line = 42; LocationInfo locationInfo = GetLocationInfoForBuilder(builder); locationInfo.Location.PhysicalLocation.Region.StartLine.Should().Be(42); }
public void AndroidStudioConverter_ConvertSarifIssue_PersistsSourceLineInfo() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.Line = 42; Location loc = GetLocationForBuilder(builder); Assert.AreEqual(42, loc.ResultFile.Region.StartLine); }
public void AndroidStudioConverter_ConvertSarifIssue_RemovesProjectDirPrefix() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = "file://$PROJECT_DIR$/mydir/myfile.xml"; Location loc = GetLocationForBuilder(builder); Assert.AreEqual("mydir/myfile.xml", loc.ResultFile.Uri.ToString()); }
public void AndroidStudioConverter_GetShortDescription_UsesDescriptionIfPresent() { AndroidStudioProblem.Builder builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.Description = "Cute fluffy kittens"; var uut = new AndroidStudioProblem(builder); string result = AndroidStudioConverter.GetShortDescriptionForProblem(uut); Assert.Equal("Cute fluffy kittens", result); }
public void AndroidStudioConverter_ConvertToSarifResult_EmptyHintsDoNotAffectDescription() { AndroidStudioProblem.Builder builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.Description = "hungry EVIL zombies"; var uut = new AndroidStudioProblem(builder); Result result = new AndroidStudioConverter().ConvertProblemToSarifResult(uut); Assert.Equal("hungry EVIL zombies", result.Message.Text); }
public void AndroidStudioConverter_ConvertToSarifResult_SeverityIsPersistedInProperties() { AndroidStudioProblem.Builder builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.Severity = "warning"; var uut = new AndroidStudioProblem(builder); Result result = new AndroidStudioConverter().ConvertProblemToSarifResult(uut); result.PropertyNames.Count.Should().Be(1); result.GetProperty("severity").Should().Be("warning"); }
public void AndroidStudioConverter_ConvertToSarifResult_AttributeKeyIsPersistedInProperties() { AndroidStudioProblem.Builder builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.AttributeKey = "key"; var uut = new AndroidStudioProblem(builder); Result result = new AndroidStudioConverter().ConvertProblemToSarifResult(uut); result.PropertyNames.Count.Should().Be(1); result.GetProperty("attributeKey").Should().Be("key"); }
public void AndroidStudioConverter_ConvertSarifResult_RecordsTopLevelFileAsSourceFile() { AndroidStudioProblem.Builder builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = "expected_file.java"; builder.EntryPointType = "file"; builder.EntryPointName = "bad_file.java"; Location loc = GetLocationInfoForBuilder(builder).Location; loc.PhysicalLocation.ArtifactLocation.Uri.ToString().Should().Be("expected_file.java"); }
public void AndroidStudioConverter_ConvertSarifResult_DoesNotRecordTopLevelEntryPointAsSourceFile() { AndroidStudioProblem.Builder builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = null; builder.EntryPointType = "file"; builder.EntryPointName = "expected_file.java"; Location loc = GetLocationInfoForBuilder(builder).Location; loc.PhysicalLocation.Should().BeNull(); }
public void AndroidStudioConverter_ConvertSarifIssue_RecordsTopLevelFileAsSourceFile() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = "expected_file.java"; builder.EntryPointType = "file"; builder.EntryPointName = "bad_file.java"; Location loc = GetLocationForBuilder(builder); Assert.AreEqual("expected_file.java", loc.ResultFile.Uri.ToString()); }
public void AndroidStudioConverter_ConvertToSarifIssue_EmptyHintsDoNotAffectDescription() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.Description = "hungry EVIL zombies"; var uut = new AndroidStudioProblem(builder); Result result = AndroidStudioConverter.ConvertProblemToSarifIssue(uut); Assert.IsNull(result.ShortMessage); Assert.AreEqual("hungry EVIL zombies", result.FullMessage); }
public void AndroidStudioConverter_ConvertSarifIssue_DoesNotRecordTopLevelEntryPointAsSourceFile() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = null; builder.EntryPointType = "file"; builder.EntryPointName = "expected_file.java"; Location loc = GetLocationForBuilder(builder); Assert.IsNull(loc.ResultFile); }
public void AndroidStudioConverter_ConvertToSarifResult_SeverityIsPersistedInProperties() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.Severity = "warning"; var uut = new AndroidStudioProblem(builder); Result result = new AndroidStudioConverter().ConvertProblemToSarifResult(uut); result.Properties.Should().Equal(new Dictionary <string, string> { { "severity", "warning" } }); }
public void AndroidStudioConverter_ConvertToSarifResult_MultiplePropertiesArePersisted() { AndroidStudioProblem.Builder builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.AttributeKey = "key"; builder.Severity = "warning"; var uut = new AndroidStudioProblem(builder); Result result = new AndroidStudioConverter().ConvertProblemToSarifResult(uut); result.PropertyNames.Count.Should().Be(2); result.GetProperty("severity").Should().Be("warning"); result.GetProperty("attributeKey").Should().Be("key"); }
public void AndroidStudioConverter_ConvertToSarifIssue_AttributeKeyIsPersistedInProperties() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.AttributeKey = "key"; var uut = new AndroidStudioProblem(builder); Result result = AndroidStudioConverter.ConvertProblemToSarifIssue(uut); result.Properties.Should().Equal(new Dictionary <string, string> { { "attributeKey", "key" } }); }
public void AndroidStudioConverter_ConvertSarifResult_CanRecordSourceFileAndModule() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = "File Goes Here"; builder.Package = null; builder.Module = "LastResortModule"; builder.EntryPointName = null; var expectedLocation = new Location { PhysicalLocation = new PhysicalLocation { FileLocation = new FileLocation { Uri = new Uri("File Goes Here", UriKind.RelativeOrAbsolute) }, }, FullyQualifiedLogicalName = "LastResortModule" }; var expectedLogicalLocations = new Dictionary <string, LogicalLocation> { { "LastResortModule", new LogicalLocation { ParentKey = null, Kind = LogicalLocationKind.Module } } }; var converter = new AndroidStudioConverter(); Result result = converter.ConvertProblemToSarifResult(new AndroidStudioProblem(builder)); result.Locations[0].ValueEquals(expectedLocation).Should().BeTrue(); foreach (string key in expectedLogicalLocations.Keys) { expectedLogicalLocations[key].ValueEquals(converter.LogicalLocationsDictionary[key]).Should().BeTrue(); } converter.LogicalLocationsDictionary.Count.Should().Be(expectedLogicalLocations.Count); }
public void AndroidStudioConverter_ConvertSarifResult_RecordsModuleAsTopLevelIfPresent() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = null; builder.Module = "my_fancy_binary"; builder.EntryPointType = "method"; builder.EntryPointName = "my_method"; var expectedLocation = new Location { FullyQualifiedLogicalName = "my_fancy_binary\\my_method", }; var expectedLogicalLocations = new Dictionary <string, LogicalLocation> { { "my_fancy_binary", new LogicalLocation { ParentKey = null, Kind = LogicalLocationKind.Module } }, { @"my_fancy_binary\my_method", new LogicalLocation { ParentKey = "my_fancy_binary", Name = "my_method", Kind = LogicalLocationKind.Member } }, }; var converter = new AndroidStudioConverter(); Result result = converter.ConvertProblemToSarifResult(new AndroidStudioProblem(builder)); result.Locations[0].ValueEquals(expectedLocation).Should().BeTrue(); foreach (string key in expectedLogicalLocations.Keys) { expectedLogicalLocations[key].ValueEquals(converter.LogicalLocationsDictionary[key]).Should().BeTrue(); } converter.LogicalLocationsDictionary.Count.Should().Be(expectedLogicalLocations.Count); }
public void AndroidStudioConverter_ConvertSarifResult_CanRecordSourceFileAndModule() { var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder(); builder.File = "File Goes Here"; builder.Package = null; builder.Module = "LastResortModule"; builder.EntryPointName = null; var expectedLocation = new Location { PhysicalLocation = new PhysicalLocation { ArtifactLocation = new ArtifactLocation { Uri = new Uri("File Goes Here", UriKind.RelativeOrAbsolute) }, }, LogicalLocation = new LogicalLocation { FullyQualifiedName = "LastResortModule", Index = 0 } }; var expectedLogicalLocations = new List <LogicalLocation> { new LogicalLocation { Kind = LogicalLocationKind.Module, FullyQualifiedName = "LastResortModule" } }; var converter = new AndroidStudioConverter(); Result result = converter.ConvertProblemToSarifResult(new AndroidStudioProblem(builder)); result.Locations[0].ValueEquals(expectedLocation).Should().BeTrue(); ValidateLogicalLocations(expectedLogicalLocations, converter.LogicalLocations); }