Exemplo n.º 1
0
        public static void GetHashCodeReturnsDifferentValuesForDifferentPositions()
        {
            var left  = new TestableSyntaxNode(new Position(4, 2));
            var right = new TestableSyntaxNode(new Position(2, 4));

            Assert.NotEqual(left.GetHashCode(), right.GetHashCode());
        }
Exemplo n.º 2
0
        public static void GetHashCodeReturnsSameValuesForSamePositions()
        {
            var left  = new TestableSyntaxNode(new Position(4, 2));
            var right = new TestableSyntaxNode(new Position(4, 2));

            Assert.Equal(left.GetHashCode(), right.GetHashCode());
        }
Exemplo n.º 3
0
        public static void EqualsReturnsFalseWhenSpanIsDifferent()
        {
            var left  = new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(4, 2));
            var right = new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(2, 4));

            Assert.False(left.Equals(right));
        }
Exemplo n.º 4
0
        public static void EqualsReturnsTrueWhenKindAndSpanAreTheSame()
        {
            var left  = new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(4, 2));
            var right = new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(4, 2));

            Assert.True(left.Equals(right));
        }
Exemplo n.º 5
0
        public static void EqualsReturnsTrueWhenPositionIsSame()
        {
            var left  = new TestableSyntaxNode(new Position(4, 2));
            var right = new TestableSyntaxNode(new Position(4, 2));

            Assert.True(left.Equals(right));
        }
Exemplo n.º 6
0
        public static void EqualsReturnsFalseWhenPositionIsDifferent()
        {
            var left  = new TestableSyntaxNode(new Position(4, 2));
            var right = new TestableSyntaxNode(new Position(2, 4));

            Assert.False(left.Equals(right));
        }
Exemplo n.º 7
0
        public static void TryGetDescriptionReturnsEmptyDescriptionAndSpanGivenPositionOutsideOfItsSpan()
        {
            var    target = new TestableSyntaxNode(SyntaxKind.Template, new Span(1, 1));
            string description;
            Span   applicableTo;

            Assert.False(target.TryGetDescription(2, out description, out applicableTo));
            Assert.Equal(string.Empty, description);
            Assert.Equal(default(Span), applicableTo);
        }
Exemplo n.º 8
0
        public static void TryGetDescriptionReturnsEmptyDescriptionAndSpanWhenNodeHasNoDescriptionAttributeAndNoChildren()
        {
            var    target = new TestableSyntaxNode(SyntaxKind.Template, new Span(0, 1));
            string description;
            Span   applicableTo;

            Assert.False(target.TryGetDescription(0, out description, out applicableTo));
            Assert.Equal(string.Empty, description);
            Assert.Equal(default(Span), applicableTo);
        }
Exemplo n.º 9
0
 public static void EqualsReturnsFalseWhenChildNodesAreDifferent()
 {
     var left = new TestableSyntaxNode(
         SyntaxKind.CodeBlock,
         new TestableSyntaxNode(SyntaxKind.ClassBlockStart, new Span(0, 3)),
         new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(3, 2)));
     var right = new TestableSyntaxNode(
         SyntaxKind.CodeBlock,
         new TestableSyntaxNode(SyntaxKind.ExpressionBlockStart, new Span(0, 3)),
         new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(3, 2)));
     Assert.False(left.Equals(right));
 }
Exemplo n.º 10
0
 public static void EqualsReturnsTrueWhenChildNodesAreSame()
 {
     var left = new TestableSyntaxNode(
         SyntaxKind.CodeBlock,
         new TestableSyntaxNode(SyntaxKind.StatementBlockStart, new Span(0, 2)),
         new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(2, 2)));
     var right = new TestableSyntaxNode(
         SyntaxKind.CodeBlock,
         new TestableSyntaxNode(SyntaxKind.StatementBlockStart, new Span(0, 2)),
         new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(2, 2)));
     Assert.True(left.Equals(right));
 }
Exemplo n.º 11
0
        public static void TryGetDescriptionReturnsDescriptionAndSpanOfChildNodeWhoseSpanContainsGivenPosition()
        {
            SyntaxNode child          = new TestableSyntaxNodeWithDescription(new Span(0, 2));
            var        childAttribute = typeof(TestableSyntaxNodeWithDescription).GetCustomAttributes(false).OfType <DescriptionAttribute>().Single();
            var        parent         = new TestableSyntaxNode(default(SyntaxKind), new Span(0, 4), child);
            string     description;
            Span       applicableTo;

            Assert.True(parent.TryGetDescription(0, out description, out applicableTo));
            Assert.Equal(childAttribute.Description, description);
            Assert.Equal(child.Span, applicableTo);
        }
Exemplo n.º 12
0
        public static void EqualsReturnsFalseWhenChildNodesAreDifferent()
        {
            var left = new TestableSyntaxNode(
                SyntaxKind.CodeBlock,
                new TestableSyntaxNode(SyntaxKind.ClassBlockStart, new Span(0, 3)),
                new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(3, 2)));
            var right = new TestableSyntaxNode(
                SyntaxKind.CodeBlock,
                new TestableSyntaxNode(SyntaxKind.ExpressionBlockStart, new Span(0, 3)),
                new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(3, 2)));

            Assert.False(left.Equals(right));
        }
Exemplo n.º 13
0
        public static void EqualsReturnsTrueWhenChildNodesAreSame()
        {
            var left = new TestableSyntaxNode(
                SyntaxKind.CodeBlock,
                new TestableSyntaxNode(SyntaxKind.StatementBlockStart, new Span(0, 2)),
                new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(2, 2)));
            var right = new TestableSyntaxNode(
                SyntaxKind.CodeBlock,
                new TestableSyntaxNode(SyntaxKind.StatementBlockStart, new Span(0, 2)),
                new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(2, 2)));

            Assert.True(left.Equals(right));
        }
Exemplo n.º 14
0
 public static void EqualsReturnsTrueWhenKindAndSpanAreTheSame()
 {
     var left = new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(4, 2));
     var right = new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(4, 2));
     Assert.True(left.Equals(right));
 }
Exemplo n.º 15
0
 public static void GetHashCodeReturnsDifferentValuesForDifferentPositions()
 {
     var left = new TestableSyntaxNode(new Position(4, 2));
     var right = new TestableSyntaxNode(new Position(2, 4));
     Assert.NotEqual(left.GetHashCode(), right.GetHashCode());
 }
Exemplo n.º 16
0
 public static void EqualsReturnsTrueWhenPositionIsSame()
 {
     var left = new TestableSyntaxNode(new Position(4, 2));
     var right = new TestableSyntaxNode(new Position(4, 2));
     Assert.True(left.Equals(right));
 }
Exemplo n.º 17
0
 public static void EqualsReturnsFalseWhenPositionIsDifferent()
 {
     var left = new TestableSyntaxNode(new Position(4, 2));
     var right = new TestableSyntaxNode(new Position(2, 4));
     Assert.False(left.Equals(right));            
 }
Exemplo n.º 18
0
 public static void EqualsReturnsFalseWhenSpanIsDifferent()
 {
     var left = new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(4, 2));
     var right = new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(2, 4));
     Assert.False(left.Equals(right));            
 }
Exemplo n.º 19
0
 public static void GetHashCodeReturnsSameValuesForSamePositions()
 {
     var left = new TestableSyntaxNode(new Position(4, 2));
     var right = new TestableSyntaxNode(new Position(4, 2));
     Assert.Equal(left.GetHashCode(), right.GetHashCode());
 }
Exemplo n.º 20
0
 public static void TryGetDescriptionReturnsDescriptionAndSpanOfChildNodeWhoseSpanContainsGivenPosition()
 {
     SyntaxNode child = new TestableSyntaxNodeWithDescription(new Span(0, 2));
     var childAttribute = typeof(TestableSyntaxNodeWithDescription).GetCustomAttributes(false).OfType<DescriptionAttribute>().Single();
     var parent = new TestableSyntaxNode(default(SyntaxKind), new Span(0, 4), child);
     string description;
     Span applicableTo;
     Assert.True(parent.TryGetDescription(0, out description, out applicableTo));
     Assert.Equal(childAttribute.Description, description);
     Assert.Equal(child.Span, applicableTo);
 }
Exemplo n.º 21
0
 public static void TryGetDescriptionReturnsEmptyDescriptionAndSpanGivenPositionOutsideOfItsSpan()
 {
     var target = new TestableSyntaxNode(SyntaxKind.Template, new Span(1, 1));
     string description;
     Span applicableTo;
     Assert.False(target.TryGetDescription(2, out description, out applicableTo));
     Assert.Equal(string.Empty, description);
     Assert.Equal(default(Span), applicableTo);
 }
Exemplo n.º 22
0
        public static void GetTextReturnsSubstringOfTemplateBasedOnSpan()
        {
            var node = new TestableSyntaxNode(SyntaxKind.DirectiveName, new Span(4, 9));

            Assert.Equal("directive", node.GetText("<#@ directive #>"));
        }
Exemplo n.º 23
0
 public static void GetTextReturnsSubstringOfTemplateBasedOnSpan()
 {
     var node = new TestableSyntaxNode(SyntaxKind.DirectiveName, new Span(4, 9));
     Assert.Equal("directive", node.GetText("<#@ directive #>"));
 }
Exemplo n.º 24
0
 public static void TryGetDescriptionReturnsEmptyDescriptionAndSpanWhenNodeHasNoDescriptionAttributeAndNoChildren()
 {
     var target = new TestableSyntaxNode(SyntaxKind.Template, new Span(0, 1));
     string description;
     Span applicableTo;
     Assert.False(target.TryGetDescription(0, out description, out applicableTo));
     Assert.Equal(string.Empty, description);
     Assert.Equal(default(Span), applicableTo);
 }