Esempio n. 1
0
        public static void TryGetDescriptionReturnsDescriptionAndSpanOfParentIfChildsDescriptionIsEmpty()
        {
            var    parent          = new TestableSyntaxNodeWithDescription(new Span(0, 4), new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(0, 2)));
            var    parentAttribute = typeof(TestableSyntaxNodeWithDescription).GetCustomAttributes(false).OfType <DescriptionAttribute>().Single();
            string description;
            Span   applicableTo;

            Assert.True(parent.TryGetDescription(0, out description, out applicableTo));
            Assert.Equal(parentAttribute.Description, description);
            Assert.Equal(parent.Span, applicableTo);
        }
Esempio n. 2
0
        public static void TryGetDescriptionReturnsDescriptionAndSpanOfNodeWhenNodeHasNoChildren()
        {
            var    target    = new TestableSyntaxNodeWithDescription(new Span(0, 1));
            var    attribute = typeof(TestableSyntaxNodeWithDescription).GetCustomAttributes(false).OfType <DescriptionAttribute>().Single();
            string description;
            Span   applicableTo;

            Assert.True(target.TryGetDescription(0, out description, out applicableTo));
            Assert.Equal(attribute.Description, description);
            Assert.Equal(target.Span, applicableTo);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
 public static void TryGetDescriptionReturnsDescriptionAndSpanOfParentIfChildsDescriptionIsEmpty()
 {
     var parent = new TestableSyntaxNodeWithDescription(new Span(0, 4), new TestableSyntaxNode(SyntaxKind.BlockEnd, new Span(0, 2)));
     var parentAttribute = typeof(TestableSyntaxNodeWithDescription).GetCustomAttributes(false).OfType<DescriptionAttribute>().Single();
     string description;
     Span applicableTo;
     Assert.True(parent.TryGetDescription(0, out description, out applicableTo));
     Assert.Equal(parentAttribute.Description, description);
     Assert.Equal(parent.Span, applicableTo);
 }
Esempio n. 5
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);
 }
Esempio n. 6
0
 public static void TryGetDescriptionReturnsDescriptionAndSpanOfNodeWhenNodeHasNoChildren()
 {
     var target = new TestableSyntaxNodeWithDescription(new Span(0, 1));
     var attribute = typeof(TestableSyntaxNodeWithDescription).GetCustomAttributes(false).OfType<DescriptionAttribute>().Single();
     string description;
     Span applicableTo;
     Assert.True(target.TryGetDescription(0, out description, out applicableTo));
     Assert.Equal(attribute.Description, description);
     Assert.Equal(target.Span, applicableTo);
 }