You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
203 lines
3.8 KiB
203 lines
3.8 KiB
using NUnit.Framework; |
|
using ICSharpCode.NRefactory.CSharp.CodeIssues; |
|
using ICSharpCode.NRefactory.CSharp.CodeActions; |
|
using ICSharpCode.NRefactory.CSharp.Refactoring; |
|
using System.Linq; |
|
|
|
namespace ICSharpCode.NRefactory.CSharp.CodeIssues.UnresolvedType |
|
{ |
|
[TestFixture] |
|
public class UnresolvedTypeActionInsideNamespaceTests : ContextActionTestBase |
|
{ |
|
[Test] |
|
public void ShouldInsertUsingStatement() |
|
{ |
|
string testCode = |
|
@"namespace TestNamespace |
|
{ |
|
class TestClass |
|
{ |
|
private $List<string> stringList; |
|
} |
|
}"; |
|
|
|
string expectedOutput = |
|
@"namespace TestNamespace |
|
{ |
|
using System.Collections.Generic; |
|
class TestClass |
|
{ |
|
private List<string> stringList; |
|
} |
|
}"; |
|
|
|
formattingOptions.UsingPlacement = UsingPlacement.InsideNamespace; |
|
formattingOptions.BlankLinesAfterUsings = 0; |
|
Test(new AddUsingAction(), testCode, expectedOutput); |
|
} |
|
|
|
[Test] |
|
[Ignore("Add using does not honor the blank line setting yet")] |
|
public void ShouldAddBlankLinesBeforeUsingStatement() |
|
{ |
|
string testCode = |
|
@"namespace TestNamespace |
|
{ |
|
class TestClass |
|
{ |
|
private $List<string> stringList; |
|
} |
|
}"; |
|
|
|
string expectedOutput = |
|
@"namespace TestNamespace |
|
{ |
|
|
|
|
|
using System.Collections.Generic; |
|
class TestClass |
|
{ |
|
private List<string> stringList; |
|
} |
|
}"; |
|
|
|
formattingOptions.UsingPlacement = UsingPlacement.InsideNamespace; |
|
formattingOptions.BlankLinesBeforeUsings = 2; |
|
formattingOptions.BlankLinesAfterUsings = 0; |
|
Test(new AddUsingAction(), testCode, expectedOutput); |
|
} |
|
|
|
[Test] |
|
[Ignore("Add using does not honor the blank line setting yet")] |
|
public void ShouldAddBlankLinesAfterUsingStatements() |
|
{ |
|
string testCode = |
|
@"namespace TestNamespace |
|
{ |
|
class TestClass |
|
{ |
|
private $List<string> stringList; |
|
} |
|
}"; |
|
|
|
string expectedOutput = |
|
@"namespace TestNamespace |
|
{ |
|
using System.Collections.Generic; |
|
|
|
|
|
class TestClass |
|
{ |
|
private List<string> stringList; |
|
} |
|
}"; |
|
|
|
formattingOptions.UsingPlacement = UsingPlacement.InsideNamespace; |
|
formattingOptions.BlankLinesAfterUsings = 2; |
|
Test(new AddUsingAction(), testCode, expectedOutput); |
|
} |
|
|
|
[Test] |
|
[Ignore("Something is wrong with the blank lines")] |
|
public void ShouldAddUsingAfterExistingUsings() |
|
{ |
|
string testCode = |
|
@"namespace TestNamespace |
|
{ |
|
using System; |
|
|
|
class TestClass |
|
{ |
|
private $List<string> stringList; |
|
} |
|
}"; |
|
|
|
string expectedOutput = |
|
@"namespace TestNamespace |
|
{ |
|
using System; |
|
using System.Collections.Generic; |
|
|
|
class TestClass |
|
{ |
|
private List<string> stringList; |
|
} |
|
}"; |
|
|
|
formattingOptions.UsingPlacement = UsingPlacement.InsideNamespace; |
|
Test(new AddUsingAction(), testCode, expectedOutput); |
|
} |
|
|
|
[Test] |
|
[Ignore("Add using does not honor the blank line setting yet")] |
|
public void ShouldAddUsingInMostNestedNamespace() |
|
{ |
|
string testCode = |
|
@"namespace OuterNamespace |
|
{ |
|
namespace InnerNamespace |
|
{ |
|
class TestClass |
|
{ |
|
private $List<string> stringList; |
|
} |
|
} |
|
}"; |
|
|
|
string expectedOutput = |
|
@"namespace OuterNamespace |
|
{ |
|
namespace InnerNamespace |
|
{ |
|
using System.Collections.Generic; |
|
|
|
class TestClass |
|
{ |
|
private List<string> stringList; |
|
} |
|
} |
|
}"; |
|
|
|
formattingOptions.UsingPlacement = UsingPlacement.InsideNamespace; |
|
Test(new AddUsingAction(), testCode, expectedOutput); |
|
} |
|
|
|
[Test] |
|
[Ignore("Something is wrong with the blank lines")] |
|
public void ShouldAddUsingAfterExistingUsingsInMostNestedNamespace() |
|
{ |
|
string testCode = |
|
@"namespace OuterNamespace |
|
{ |
|
namespace InnerNamespace |
|
{ |
|
using System; |
|
|
|
class TestClass |
|
{ |
|
private $List<string> stringList; |
|
} |
|
} |
|
}"; |
|
|
|
string expectedOutput = |
|
@"namespace OuterNamespace |
|
{ |
|
namespace InnerNamespace |
|
{ |
|
using System; |
|
using System.Collections.Generic; |
|
|
|
class TestClass |
|
{ |
|
private List<string> stringList; |
|
} |
|
} |
|
}"; |
|
|
|
formattingOptions.UsingPlacement = UsingPlacement.InsideNamespace; |
|
Test(new AddUsingAction(), testCode, expectedOutput); |
|
} |
|
} |
|
} |
|
|
|
|