public void IsNameTakenMultipleChildSpaces() { parent.AddChildSpace(child); var child2 = new LocalDeclarationSpace(); parent.AddChildSpace(child2); var input = @" class Foo { void Bar() { { int $i; } } }"; var context = TestRefactoringContext.Create(input); child2.AddDeclaration("i", context.GetNode <VariableInitializer>()); Assert.That(parent.IsNameUsed("i"), "The declaration was not added to parent correctly."); Assert.That(!child.IsNameUsed("i"), "child contained the declaration, event though it shouldn't."); Assert.That(child2.IsNameUsed("i"), "child2 did not contain the declaration, event though it should have."); Assert.That(!parent.IsNameUsed("j"), "parent contained a non-existent declaration."); Assert.That(!child.IsNameUsed("j"), "parent contained a non-existent declaration."); Assert.That(!child2.IsNameUsed("j"), "parent contained a non-existent declaration."); }
static LocalDeclarationSpaceVisitor GetVisitor(out TestRefactoringContext context, string input) { context = TestRefactoringContext.Create(input); var visitor = new LocalDeclarationSpaceVisitor(); context.RootNode.AcceptVisitor(visitor); return(visitor); }
public void ContainsNameSimpleVariableDeclaration() { parent.AddChildSpace(child); var input = @" class Foo { void Bar() { int $i; } }"; var context = TestRefactoringContext.Create(input); child.AddDeclaration("i", context.GetNode <VariableInitializer>()); Assert.That(child.ContainsName("i", false), "The declaration was not added to child correctly."); Assert.That(!parent.ContainsName("i", false), "parent incorrectly contained the declaration."); Assert.That(parent.ContainsName("i", true), "parent did not contain the declaration, event though it should have."); }
public void SetUp() { compilation = TestRefactoringContext.Create("").Compilation; typeResolveContext = compilation.TypeResolveContext; intType = GetIType <int>(); }
protected static List <CodeIssue> GetIssuesWithSubIssue(CodeIssueProvider action, string input, string subIssue, out TestRefactoringContext context, bool expectErrors = false) { context = TestRefactoringContext.Create(input, expectErrors); return(new List <CodeIssue> (action.GetIssues(context, subIssue))); }
protected static List <CodeIssue> GetIssues(CodeIssueProvider action, string input, out TestRefactoringContext context, bool expectErrors = false, CSharpParser parser = null) { context = TestRefactoringContext.Create(input, expectErrors, parser); return(new List <CodeIssue> (action.GetIssues(context))); }
RefactoringContext MakeContext(string input, bool expectErrors = false) { var context = TestRefactoringContext.Create(input, expectErrors); return(context); }
protected static List <CodeIssue> GetIssues(ICodeIssueProvider action, string input, out TestRefactoringContext context) { context = TestRefactoringContext.Create(input); return(new List <CodeIssue> (action.GetIssues(context))); }