Browse Source

Started to implement tests for the inspectors.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
16ea65ad95
  1. 8
      ICSharpCode.NRefactory.Tests/CSharp/ContextAction/TestRefactoringContext.cs
  2. 143
      ICSharpCode.NRefactory.Tests/CSharp/Inspector/ConditionalToNullCoalescingInspectorTests.cs
  3. 45
      ICSharpCode.NRefactory.Tests/CSharp/Inspector/InspectionActionTestBase.cs
  4. 53
      ICSharpCode.NRefactory.Tests/CSharp/Inspector/NotImplementedExceptionInspectorTests.cs
  5. 51
      ICSharpCode.NRefactory.Tests/CSharp/Inspector/RedundantInternalInspectorTests.cs
  6. 54
      ICSharpCode.NRefactory.Tests/CSharp/Inspector/RedundantNamespaceUsageInspectorTests.cs
  7. 52
      ICSharpCode.NRefactory.Tests/CSharp/Inspector/RedundantPrivateInspectorTests.cs
  8. 53
      ICSharpCode.NRefactory.Tests/CSharp/Inspector/RedundantThisInspectorTests.cs
  9. 54
      ICSharpCode.NRefactory.Tests/CSharp/Inspector/RedundantUsingInspectorTests.cs
  10. 55
      ICSharpCode.NRefactory.Tests/CSharp/Inspector/StringIsNullOrEmptyInspectorTests.cs
  11. 53
      ICSharpCode.NRefactory.Tests/CSharp/Inspector/UseVarKeywordInspectorTests.cs
  12. 14
      ICSharpCode.NRefactory.Tests/ICSharpCode.NRefactory.Tests.csproj

8
ICSharpCode.NRefactory.Tests/CSharp/ContextAction/TestRefactoringContext.cs

@ -39,7 +39,7 @@ using System.Threading; @@ -39,7 +39,7 @@ using System.Threading;
namespace ICSharpCode.NRefactory.CSharp.ContextActions
{
class TestRefactoringContext : RefactoringContext
public class TestRefactoringContext : RefactoringContext
{
internal readonly IDocument doc;
readonly TextLocation location;
@ -112,7 +112,11 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions @@ -112,7 +112,11 @@ namespace ICSharpCode.NRefactory.CSharp.ContextActions
return doc.GetLineByOffset (offset);
}
#endregion
public string Text {
get {
return doc.Text;
}
}
public static TestRefactoringContext Create(string content)
{
int idx = content.IndexOf ("$");

143
ICSharpCode.NRefactory.Tests/CSharp/Inspector/ConditionalToNullCoalescingInspectorTests.cs

@ -0,0 +1,143 @@ @@ -0,0 +1,143 @@
//
// ConditionalToNullCoalescingInspectorTests.cs
//
// Author:
// Mike Krüger <mkrueger@xamarin.com>
//
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using NUnit.Framework;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.CSharp.ContextActions;
namespace ICSharpCode.NRefactory.CSharp.Inspector
{
[TestFixture]
public class ConditionalToNullCoalescingInspectorTests : InspectionActionTestBase
{
[Test]
public void TestInspectorCase1 ()
{
var input = @"class Foo
{
void Bar (string str)
{
string c = str != null ? str : ""default"";
}
}";
TestRefactoringContext context;
var issues = GetIssues (new ConditionalToNullCoalescingInspector (), input, out context);
Assert.AreEqual (1, issues.Count);
issues [0].Fix ();
var output = @"class Foo
{
void Bar (string str)
{
string c = str ?? ""default"";
}
}";
Assert.AreEqual (output, context.Text);
}
[Test]
public void TestInspectorCase2 ()
{
var input = @"class Foo
{
void Bar (string str)
{
string c = null != str ? str : ""default"";
}
}";
TestRefactoringContext context;
var issues = GetIssues (new ConditionalToNullCoalescingInspector (), input, out context);
Assert.AreEqual (1, issues.Count);
issues [0].Fix ();
var output = @"class Foo
{
void Bar (string str)
{
string c = str ?? ""default"";
}
}";
Assert.AreEqual (output, context.Text);
}
[Test]
public void TestInspectorCase3 ()
{
var input = @"class Foo
{
void Bar (string str)
{
string c = null == str ? ""default"" : str;
}
}";
TestRefactoringContext context;
var issues = GetIssues (new ConditionalToNullCoalescingInspector (), input, out context);
Assert.AreEqual (1, issues.Count);
issues [0].Fix ();
var output = @"class Foo
{
void Bar (string str)
{
string c = str ?? ""default"";
}
}";
Assert.AreEqual (output, context.Text);
}
[Test]
public void TestInspectorCase4 ()
{
var input = @"class Foo
{
void Bar (string str)
{
string c = str == null ? ""default"" : str;
}
}";
TestRefactoringContext context;
var issues = GetIssues (new ConditionalToNullCoalescingInspector (), input, out context);
Assert.AreEqual (1, issues.Count);
issues [0].Fix ();
var output = @"class Foo
{
void Bar (string str)
{
string c = str ?? ""default"";
}
}";
Assert.AreEqual (output, context.Text);
}
}
}

45
ICSharpCode.NRefactory.Tests/CSharp/Inspector/InspectionActionTestBase.cs

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
//
// InspectionActionTestBase.cs
//
// Author:
// Mike Krüger <mkrueger@xamarin.com>
//
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.CSharp.ContextActions;
using System.Collections.Generic;
namespace ICSharpCode.NRefactory.CSharp.Inspector
{
public abstract class InspectionActionTestBase
{
protected static List<InspectionIssue> GetIssues (IInspector action, string input, out TestRefactoringContext context)
{
context = TestRefactoringContext.Create (input);
return new List<InspectionIssue> (action.Run (context));
}
}
}

53
ICSharpCode.NRefactory.Tests/CSharp/Inspector/NotImplementedExceptionInspectorTests.cs

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
//
// NotImplementedExceptionInspectorTests.cs
//
// Author:
// Mike Krüger <mkrueger@xamarin.com>
//
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using NUnit.Framework;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.CSharp.ContextActions;
namespace ICSharpCode.NRefactory.CSharp.Inspector
{
[TestFixture]
public class NotImplementedExceptionInspectorTests : InspectionActionTestBase
{
[Test]
public void TestInspectorCase1 ()
{
var input = @"class Foo
{
void Bar (string str)
{
throw new System.NotImplementedException ();
}
}";
TestRefactoringContext context;
var issues = GetIssues (new NotImplementedExceptionInspector (), input, out context);
Assert.AreEqual (1, issues.Count);
}
}
}

51
ICSharpCode.NRefactory.Tests/CSharp/Inspector/RedundantInternalInspectorTests.cs

@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
//
// RedundantInternalInspectorTests.cs
//
// Author:
// Mike Krüger <mkrueger@xamarin.com>
//
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using NUnit.Framework;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.CSharp.ContextActions;
namespace ICSharpCode.NRefactory.CSharp.Inspector
{
[TestFixture]
public class RedundantInternalInspectorTests : InspectionActionTestBase
{
[Test]
public void TestInspectorCase1 ()
{
var input = @"internal class Foo
{
internal void Bar (string str)
{
}
}";
TestRefactoringContext context;
var issues = GetIssues (new RedundantInternalInspector (), input, out context);
Assert.AreEqual (1, issues.Count);
}
}
}

54
ICSharpCode.NRefactory.Tests/CSharp/Inspector/RedundantNamespaceUsageInspectorTests.cs

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
//
// RedundantNamespaceUsageInspectorTests.cs
//
// Author:
// Mike Krüger <mkrueger@xamarin.com>
//
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using NUnit.Framework;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.CSharp.ContextActions;
namespace ICSharpCode.NRefactory.CSharp.Inspector
{
[TestFixture]
public class RedundantNamespaceUsageInspectorTests : InspectionActionTestBase
{
[Test]
public void TestInspectorCase1 ()
{
var input = @"using System;
class Foo
{
void Bar (string str)
{
System.Console.WriteLine ();
}
}";
TestRefactoringContext context;
var issues = GetIssues (new RedundantNamespaceUsageInspector (), input, out context);
Assert.AreEqual (1, issues.Count);
}
}
}

52
ICSharpCode.NRefactory.Tests/CSharp/Inspector/RedundantPrivateInspectorTests.cs

@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
//
// RedundantPrivateInspectorTests.cs
//
// Author:
// Mike Krüger <mkrueger@xamarin.com>
//
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using NUnit.Framework;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.CSharp.ContextActions;
namespace ICSharpCode.NRefactory.CSharp.Inspector
{
[TestFixture]
public class RedundantPrivateInspectorTests : InspectionActionTestBase
{
[Test]
public void TestInspectorCase1 ()
{
var input = @"class Foo
{
private void Bar (string str)
{
}
}";
TestRefactoringContext context;
var issues = GetIssues (new RedundantPrivateInspector (), input, out context);
Assert.AreEqual (1, issues.Count);
}
}
}

53
ICSharpCode.NRefactory.Tests/CSharp/Inspector/RedundantThisInspectorTests.cs

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
//
// RedundantThisInspectorTests.cs
//
// Author:
// Mike Krüger <mkrueger@xamarin.com>
//
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using NUnit.Framework;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.CSharp.ContextActions;
namespace ICSharpCode.NRefactory.CSharp.Inspector
{
[TestFixture]
public class RedundantThisInspectorTests : InspectionActionTestBase
{
[Test]
public void TestInspectorCase1 ()
{
var input = @"class Foo
{
void Bar (string str)
{
this.Bar (str);
}
}";
TestRefactoringContext context;
var issues = GetIssues (new RedundantThisInspector (), input, out context);
Assert.AreEqual (1, issues.Count);
}
}
}

54
ICSharpCode.NRefactory.Tests/CSharp/Inspector/RedundantUsingInspectorTests.cs

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
//
// RedundantUsingInspectorTests.cs
//
// Author:
// Mike Krüger <mkrueger@xamarin.com>
//
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using NUnit.Framework;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.CSharp.ContextActions;
namespace ICSharpCode.NRefactory.CSharp.Inspector
{
[TestFixture]
public class RedundantUsingInspectorTests : InspectionActionTestBase
{
[Test]
public void TestInspectorCase1 ()
{
var input = @"using System;
class Foo
{
void Bar (string str)
{
}
}";
TestRefactoringContext context;
var issues = GetIssues (new RedundantUsingInspector (), input, out context);
Assert.AreEqual (1, issues.Count);
}
}
}

55
ICSharpCode.NRefactory.Tests/CSharp/Inspector/StringIsNullOrEmptyInspectorTests.cs

@ -0,0 +1,55 @@ @@ -0,0 +1,55 @@
//
// StringIsNullOrEmptyInspectorTests.cs
//
// Author:
// Mike Krüger <mkrueger@xamarin.com>
//
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using NUnit.Framework;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.CSharp.ContextActions;
namespace ICSharpCode.NRefactory.CSharp.Inspector
{
[TestFixture]
public class StringIsNullOrEmptyInspectorTests : InspectionActionTestBase
{
[Test]
public void TestInspectorCase1 ()
{
var input = @"class Foo
{
void Bar (string str)
{
if (str != null && str != """")
;
}
}";
TestRefactoringContext context;
var issues = GetIssues (new StringIsNullOrEmptyInspector (), input, out context);
Assert.AreEqual (1, issues.Count);
}
}
}

53
ICSharpCode.NRefactory.Tests/CSharp/Inspector/UseVarKeywordInspectorTests.cs

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
//
// UseVarKeywordInspectorTests.cs
//
// Author:
// Mike Krüger <mkrueger@xamarin.com>
//
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using NUnit.Framework;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.CSharp.ContextActions;
namespace ICSharpCode.NRefactory.CSharp.Inspector
{
[TestFixture]
public class UseVarKeywordInspectorTests : InspectionActionTestBase
{
[Test]
public void TestInspectorCase1 ()
{
var input = @"class Foo
{
void Bar (object o)
{
Foo foo = (Foo)o;
}
}";
TestRefactoringContext context;
var issues = GetIssues (new UseVarKeywordInspector (), input, out context);
Assert.AreEqual (1, issues.Count);
}
}
}

14
ICSharpCode.NRefactory.Tests/ICSharpCode.NRefactory.Tests.csproj

@ -71,9 +71,8 @@ @@ -71,9 +71,8 @@
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="nunit.framework, Version=2.6.0.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
<Reference Include="nunit.framework">
<HintPath>..\..\Mono.Cecil\Test\libs\nunit-2.5.10\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
@ -238,6 +237,16 @@ @@ -238,6 +237,16 @@
<Compile Include="CSharp\ContextAction\AddAnotherAccessorTests.cs" />
<Compile Include="CSharp\ContextAction\RemoveRegionTests.cs" />
<Compile Include="CSharp\ContextAction\GeneratePropertyTests.cs" />
<Compile Include="CSharp\Inspector\ConditionalToNullCoalescingInspectorTests.cs" />
<Compile Include="CSharp\Inspector\InspectionActionTestBase.cs" />
<Compile Include="CSharp\Inspector\NotImplementedExceptionInspectorTests.cs" />
<Compile Include="CSharp\Inspector\RedundantInternalInspectorTests.cs" />
<Compile Include="CSharp\Inspector\RedundantNamespaceUsageInspectorTests.cs" />
<Compile Include="CSharp\Inspector\RedundantPrivateInspectorTests.cs" />
<Compile Include="CSharp\Inspector\RedundantThisInspectorTests.cs" />
<Compile Include="CSharp\Inspector\RedundantUsingInspectorTests.cs" />
<Compile Include="CSharp\Inspector\StringIsNullOrEmptyInspectorTests.cs" />
<Compile Include="CSharp\Inspector\UseVarKeywordInspectorTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Mono.Cecil\Mono.Cecil.csproj">
@ -264,6 +273,7 @@ @@ -264,6 +273,7 @@
<Folder Include="CSharp\" />
<Folder Include="CSharp\Parser\" />
<Folder Include="CSharp\ContextAction\" />
<Folder Include="CSharp\Inspector\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>

Loading…
Cancel
Save