public static async Task FindCandidatesWithNoMatchesAsync(string code) { var classDeclaration = (await SyntaxFactory.ParseSyntaxTree(code) .GetRootAsync().ConfigureAwait(false)).DescendantNodes(_ => true).OfType <ClassDeclarationSyntax>().First(); var receiver = new MapReceiver(); var context = MapReceiverTests.GetContext(classDeclaration); receiver.OnVisitSyntaxNode(context); Assert.That(receiver.Targets.Count, Is.EqualTo(0)); }
public static async Task FindCandidatesWhenAttributeIsTargetingAnAssemblyAsync(string code) { var attributeDeclaration = (await SyntaxFactory.ParseSyntaxTree(code) .GetRootAsync().ConfigureAwait(false)).DescendantNodes(_ => true).OfType <AttributeSyntax>().First(); var receiver = new MapReceiver(); var context = MapReceiverTests.GetContext(attributeDeclaration); receiver.OnVisitSyntaxNode(context); Assert.That(receiver.Targets.Count, Is.EqualTo(1)); }