コード例 #1
0
        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.");
        }
コード例 #2
0
        static LocalDeclarationSpaceVisitor GetVisitor(out TestRefactoringContext context, string input)
        {
            context = TestRefactoringContext.Create(input);
            var visitor = new LocalDeclarationSpaceVisitor();

            context.RootNode.AcceptVisitor(visitor);
            return(visitor);
        }
コード例 #3
0
        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.");
        }
コード例 #4
0
 public void SetUp()
 {
     compilation        = TestRefactoringContext.Create("").Compilation;
     typeResolveContext = compilation.TypeResolveContext;
     intType            = GetIType <int>();
 }
コード例 #5
0
        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)));
        }
コード例 #6
0
        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)));
        }
コード例 #7
0
        RefactoringContext MakeContext(string input, bool expectErrors = false)
        {
            var context = TestRefactoringContext.Create(input, expectErrors);

            return(context);
        }
コード例 #8
0
        protected static List <CodeIssue> GetIssues(ICodeIssueProvider action, string input, out TestRefactoringContext context)
        {
            context = TestRefactoringContext.Create(input);

            return(new List <CodeIssue> (action.GetIssues(context)));
        }