示例#1
0
        public static async Task FindCandidatesWithNoAttributes()
        {
            var classDeclaration = (await SyntaxFactory.ParseSyntaxTree(
                                        "public class Source { }").GetRootAsync().ConfigureAwait(false)).DescendantNodes(_ => true).OfType <ClassDeclarationSyntax>().First();

            var receiver = new MapToReceiver();

            receiver.OnVisitSyntaxNode(classDeclaration);

            Assert.Multiple(() =>
            {
                Assert.That(receiver.Candidates.Count, Is.EqualTo(0));
            });
        }
示例#2
0
        public static async Task FindCandidatesWhenAttributeIsDeclaredAsMapToAttributeAsync()
        {
            var classDeclaration = (await SyntaxFactory.ParseSyntaxTree(
                                        @"[MapToAttribute]
public class Source { }").GetRootAsync().ConfigureAwait(false)).DescendantNodes(_ => true).OfType <ClassDeclarationSyntax>().First();

            var receiver = new MapToReceiver();

            receiver.OnVisitSyntaxNode(classDeclaration);

            Assert.Multiple(() =>
            {
                Assert.That(receiver.Candidates.Count, Is.GreaterThan(0));
                Assert.That(receiver.Candidates[0].Identifier.Text, Is.EqualTo("Source"));
            });
        }