Skip to content

Commit

Permalink
Add unit test for ArtifactLocation.ToLocation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Larry Golding committed Aug 18, 2020
1 parent 0d29c38 commit 21c481b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Test.UnitTests.Sarif/Core/ArtifactLocationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,28 @@ public void TryReconstructAbsoluteUri_WhenBaseUriDoesNotEndWithSlash_EnsuresSlas
wasResolved.Should().BeTrue();
resolvedUri.Should().Be(new Uri("file://c:/code/sarif-sdk/src/Sarif/CopyrightNotice.txt", UriKind.Absolute));
}

[Fact]
public void ToLocation_ProducesExpectedLocationObject()
{
const string SourceFile = "src/Sarif/Core/ArtifactLocation.cs";

var artifactLocation = new ArtifactLocation
{
Uri = new Uri(SourceFile, UriKind.Relative)
};

Location location = artifactLocation.ToLocation(lineNumber: 12, column: 9, length: 14, offset: 140);

PhysicalLocation physicalLocation = location.PhysicalLocation;
physicalLocation.ArtifactLocation.Uri.OriginalString.Should().Be(SourceFile);

Region region = physicalLocation.Region;
region.StartLine.Should().Be(12);
region.StartColumn.Should().Be(9);
region.EndColumn.Should().Be(23);
region.CharOffset.Should().Be(140);
region.CharLength.Should().Be(14);
}
}
}

0 comments on commit 21c481b

Please sign in to comment.