Permalink
Browse files

Added missing is null or empty inspector cases.

  • Loading branch information...
mkrueger committed Mar 23, 2012
1 parent 41d5b50 commit 6b4150680ffa5efe9842e0afeeb49bd6c7b72300
Showing with 210 additions and 9 deletions.
  1. +210 −9 ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/StringIsNullOrEmptyInspectorTests.cs
@@ -36,7 +36,7 @@ namespace ICSharpCode.NRefactory.CSharp.CodeIssues
public class StringIsNullOrEmptyInspectorTests : InspectionActionTestBase
{
[Test]
- public void TestInspectorCase1 ()
+ public void TestInspectorCaseNS1 ()
{
var input = @"class Foo
{
@@ -61,7 +61,7 @@ void Bar (string str)
}
[Test]
- public void TestInspectorCase2 ()
+ public void TestInspectorCaseNS2 ()
{
var input = @"class Foo
{
@@ -86,7 +86,7 @@ void Bar (string str)
}
[Test]
- public void TestInspectorCase3 ()
+ public void TestInspectorCaseNS3 ()
{
var input = @"class Foo
{
@@ -111,13 +111,114 @@ void Bar (string str)
}
[Test]
- public void TestInspectorCase4 ()
+ public void TestInspectorCaseNS4 ()
{
var input = @"class Foo
{
void Bar (string str)
{
- if (str != null && """" != str)
+ if (str != null && str != """")
+ ;
+ }
+}";
+
+ TestRefactoringContext context;
+ var issues = GetIssues (new StringIsNullOrEmptyIssue (), input, out context);
+ Assert.AreEqual (1, issues.Count);
+ CheckFix (context, issues, @"class Foo
+{
+ void Bar (string str)
+ {
+ if (!string.IsNullOrEmpty (str))
+ ;
+ }
+}");
+ }
+
+ [Test]
+ public void TestInspectorCaseSN1 ()
+ {
+ var input = @"class Foo
+{
+ void Bar (string str)
+ {
+ if (str != """" && str != null)
+ ;
+ }
+}";
+
+ TestRefactoringContext context;
+ var issues = GetIssues (new StringIsNullOrEmptyIssue (), input, out context);
+ Assert.AreEqual (1, issues.Count);
+ CheckFix (context, issues, @"class Foo
+{
+ void Bar (string str)
+ {
+ if (!string.IsNullOrEmpty (str))
+ ;
+ }
+}");
+ }
+
+ [Test]
+ public void TestInspectorCaseSN2 ()
+ {
+ var input = @"class Foo
+{
+ void Bar (string str)
+ {
+ if ("""" != str && str != null)
+ ;
+ }
+}";
+
+ TestRefactoringContext context;
+ var issues = GetIssues (new StringIsNullOrEmptyIssue (), input, out context);
+ Assert.AreEqual (1, issues.Count);
+ CheckFix (context, issues, @"class Foo
+{
+ void Bar (string str)
+ {
+ if (!string.IsNullOrEmpty (str))
+ ;
+ }
+}");
+ }
+
+ [Test]
+ public void TestInspectorCaseSN3 ()
+ {
+ var input = @"class Foo
+{
+ void Bar (string str)
+ {
+ if ("""" != str && null != str)
+ ;
+ }
+}";
+
+ TestRefactoringContext context;
+ var issues = GetIssues (new StringIsNullOrEmptyIssue (), input, out context);
+ Assert.AreEqual (1, issues.Count);
+ CheckFix (context, issues, @"class Foo
+{
+ void Bar (string str)
+ {
+ if (!string.IsNullOrEmpty (str))
+ ;
+ }
+}");
+ }
+
+
+ [Test]
+ public void TestInspectorCaseSN4 ()
+ {
+ var input = @"class Foo
+{
+ void Bar (string str)
+ {
+ if (str != """" && null != str)
;
}
}";
@@ -136,7 +237,7 @@ void Bar (string str)
}
[Test]
- public void TestInspectorCase5 ()
+ public void TestInspectorCaseNS5 ()
{
var input = @"class Foo
{
@@ -161,7 +262,7 @@ void Bar (string str)
}
[Test]
- public void TestInspectorCase6 ()
+ public void TestInspectorCaseNS6 ()
{
var input = @"class Foo
{
@@ -186,7 +287,7 @@ void Bar (string str)
}
[Test]
- public void TestInspectorCase7 ()
+ public void TestInspectorCaseNS7 ()
{
var input = @"class Foo
{
@@ -211,7 +312,7 @@ void Bar (string str)
}
[Test]
- public void TestInspectorCase8 ()
+ public void TestInspectorCaseNS8 ()
{
var input = @"class Foo
{
@@ -232,6 +333,106 @@ void Bar (string str)
if (string.IsNullOrEmpty (str))
;
}
+}");
+ }
+
+ [Test]
+ public void TestInspectorCaseSN5 ()
+ {
+ var input = @"class Foo
+{
+ void Bar (string str)
+ {
+ if (str == """" || str == null)
+ ;
+ }
+}";
+
+ TestRefactoringContext context;
+ var issues = GetIssues (new StringIsNullOrEmptyIssue (), input, out context);
+ Assert.AreEqual (1, issues.Count);
+ CheckFix (context, issues, @"class Foo
+{
+ void Bar (string str)
+ {
+ if (string.IsNullOrEmpty (str))
+ ;
+ }
+}");
+ }
+
+ [Test]
+ public void TestInspectorCaseSN6 ()
+ {
+ var input = @"class Foo
+{
+ void Bar (string str)
+ {
+ if ("""" == str || str == null)
+ ;
+ }
+}";
+
+ TestRefactoringContext context;
+ var issues = GetIssues (new StringIsNullOrEmptyIssue (), input, out context);
+ Assert.AreEqual (1, issues.Count);
+ CheckFix (context, issues, @"class Foo
+{
+ void Bar (string str)
+ {
+ if (string.IsNullOrEmpty (str))
+ ;
+ }
+}");
+ }
+
+ [Test]
+ public void TestInspectorCaseSN7 ()
+ {
+ var input = @"class Foo
+{
+ void Bar (string str)
+ {
+ if ("""" == str || null == str)
+ ;
+ }
+}";
+
+ TestRefactoringContext context;
+ var issues = GetIssues (new StringIsNullOrEmptyIssue (), input, out context);
+ Assert.AreEqual (1, issues.Count);
+ CheckFix (context, issues, @"class Foo
+{
+ void Bar (string str)
+ {
+ if (string.IsNullOrEmpty (str))
+ ;
+ }
+}");
+ }
+
+ [Test]
+ public void TestInspectorCaseSN8 ()
+ {
+ var input = @"class Foo
+{
+ void Bar (string str)
+ {
+ if (str == """" || null == str)
+ ;
+ }
+}";
+
+ TestRefactoringContext context;
+ var issues = GetIssues (new StringIsNullOrEmptyIssue (), input, out context);
+ Assert.AreEqual (1, issues.Count);
+ CheckFix (context, issues, @"class Foo
+{
+ void Bar (string str)
+ {
+ if (string.IsNullOrEmpty (str))
+ ;
+ }
}");
}
}

0 comments on commit 6b41506

Please sign in to comment.