2
// RedundantConstructorTest.cs
5
// Ji Kun <jikun.nus@gmail.com>
7
// Copyright (c) 2013 Ji Kun
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
using NUnit.Framework;
28
using ICSharpCode.NRefactory.CSharp.Refactoring;
29
using ICSharpCode.NRefactory.CSharp.CodeActions;
31
namespace ICSharpCode.NRefactory.CSharp.CodeIssues
34
public class RedundantConstructorTests : InspectionActionTestBase
37
public void TestInspectorCase1()
39
var input = @"using System;class Test {private int member; public Test(){}}";
41
TestRefactoringContext context;
42
var issues = GetIssues(new RedundantConstructorIssue(), input, out context);
43
Assert.AreEqual(1, issues.Count);
45
CheckFix(context, issues, @"using System;class Test {private int member; }");
49
public void TestInspectorCase2()
51
var input = @"using System;class Test {private int member;public Test(){} static Test(){}}";
53
TestRefactoringContext context;
54
var issues = GetIssues(new RedundantConstructorIssue(), input, out context);
55
Assert.AreEqual(1, issues.Count);
57
CheckFix(context, issues, @"using System;class Test {private int member; static Test(){}}");
61
public void TestResharperDisable()
63
var input = @"using System;
64
//Resharper disable RedundantConstructor
68
//Resharper restore RedundantConstructor
71
TestRefactoringContext context;
72
var issues = GetIssues(new RedundantConstructorIssue(), input, out context);
73
Assert.AreEqual(0, issues.Count);
77
public void TestNegateCase1()
79
var input = @"using System;class Test {public Test(){;}}";
81
TestRefactoringContext context;
82
var issues = GetIssues(new RedundantConstructorIssue(), input, out context);
83
Assert.AreEqual(0, issues.Count);
87
public void TestNegateCase2()
89
var input = @"using System;class Test {public Test(){;} private Test(){}}";
91
TestRefactoringContext context;
92
var issues = GetIssues(new RedundantConstructorIssue(), input, out context);
93
Assert.AreEqual(0, issues.Count);
b'\\ No newline at end of file'