4using Microsoft.VisualStudio.TestTools.UnitTesting;
6using System.Threading.Tasks;
21@"using System.Collections.Generic;
24 Assert.IsTrue((await GetRootAsync(code)).HasUsing(
"System.Collections.Generic"));
30 var code =
"public class HasUsingWhenNodeDoesNotHaveUsingStatememt { }";
31 Assert.IsFalse((await GetRootAsync(code)).HasUsing(
"System.Collections.Generic"));
42 public Guid NewGuid() => Guid.NewGuid();
44 var rootNode = await GetRootAsync(code);
45 var invocationNode = rootNode.DescendantNodes(_ =>
true)
46 .Where(_ => _.IsKind(SyntaxKind.InvocationExpression)).First();
48 Assert.IsNotNull(invocationNode.FindParent<ArrowExpressionClauseSyntax>());
59 public Guid NewGuid() => Guid.NewGuid();
61 var rootNode = await GetRootAsync(code);
62 var invocationNode = rootNode.DescendantNodes(_ =>
true)
63 .Where(_ => _.IsKind(SyntaxKind.InvocationExpression)).First();
65 Assert.IsNull(invocationNode.FindParent<AwaitExpressionSyntax>());
71 var code =
"public class A { }";
72 var rootNode = await GetRootAsync(code);
73 Assert.IsNull(rootNode.FindParent<AwaitExpressionSyntax>());
76 private async Task<SyntaxNode> GetRootAsync(
string code)
78 return await CSharpSyntaxTree.ParseText(code).GetRootAsync();
async Task FindParentWhenParentTypeExists()
async Task HasUsingWhenNodeHasUsingStatememt()
async Task FindParentWhenParentIsNull()
void HasUsingWhenSymbolIsNull()
async Task HasUsingWhenNodeDoesNotHaveUsingStatememt()
async Task FindParentWhenParentTypeDoesNotExists()