public void GetOffSet_SpanIsOwner_ReturnsOffset() { // Arrange var builder = SyntaxListBuilder <SyntaxToken> .Create(); builder.Add(SyntaxFactory.Token(SyntaxKind.Marker, "Hello, ")); builder.Add(SyntaxFactory.Token(SyntaxKind.Marker, "World")); var node = SyntaxFactory.MarkupTextLiteral(builder.ToList()).CreateRed(null, 13); var change = new SourceChange(15, 2, "heyo"); // Act var result = change.GetOffset(node); // Act Assert.Equal(2, result); }
public void GetOffSet_SpanIsNotOwnerOfChange_ThrowsException() { // Arrange var builder = SyntaxListBuilder <SyntaxToken> .Create(); builder.Add(SyntaxFactory.Token(SyntaxKind.Marker, "Hello, ")); builder.Add(SyntaxFactory.Token(SyntaxKind.Marker, "World")); var node = SyntaxFactory.MarkupTextLiteral(builder.ToList()).CreateRed(null, 13); var change = new SourceChange(12, 2, "heyo"); var expected = $"The node '{node}' is not the owner of change '{change}'."; // Act & Assert var exception = Assert.Throws <InvalidOperationException>(() => { change.GetOffset(node); }); Assert.Equal(expected, exception.Message); }