~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory.Tests/CSharp/CodeIssues/ParameterHidesMemberIssueTests.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
Import upstream version 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
// ParameterHidesMemberIssueTests.cs
 
3
// 
 
4
// Author:
 
5
//      Mansheng Yang <lightyang0@gmail.com>
 
6
// 
 
7
// Copyright (c) 2012 Mansheng Yang <lightyang0@gmail.com>
 
8
// 
 
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:
 
15
// 
 
16
// The above copyright notice and this permission notice shall be included in
 
17
// all copies or substantial portions of the Software.
 
18
// 
 
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
 
25
// THE SOFTWARE.
 
26
 
 
27
using ICSharpCode.NRefactory.CSharp.Refactoring;
 
28
using NUnit.Framework;
 
29
 
 
30
namespace ICSharpCode.NRefactory.CSharp.CodeIssues
 
31
{
 
32
        [TestFixture]
 
33
        public class ParameterHidesMemberIssueTests : InspectionActionTestBase
 
34
        {
 
35
                [Test]
 
36
                public void TestField ()
 
37
                {
 
38
                        var input = @"
 
39
class TestClass
 
40
{
 
41
        int i;
 
42
        void TestMethod (int i, int j)
 
43
        {
 
44
        }
 
45
}";
 
46
                        Test<ParameterHidesMemberIssue> (input, 1);
 
47
                }
 
48
 
 
49
                [Test]
 
50
                public void TestMethod ()
 
51
                {
 
52
                        var input = @"
 
53
class TestClass
 
54
{
 
55
        void TestMethod2 ()
 
56
        { }
 
57
        void TestMethod (int TestMethod2)
 
58
        {
 
59
        }
 
60
}";
 
61
                        Test<ParameterHidesMemberIssue> (input, 1);
 
62
                }
 
63
 
 
64
                [Test]
 
65
                public void TestConstructor ()
 
66
                {
 
67
                        var input = @"
 
68
class TestClass
 
69
{
 
70
        int i;
 
71
        public TestClass(int i)
 
72
        {
 
73
        }
 
74
}";
 
75
                        Test<ParameterHidesMemberIssue> (input, 0);
 
76
                }
 
77
 
 
78
                [Test]
 
79
                public void TestStatic ()
 
80
                {
 
81
                        var input = @"
 
82
class TestClass
 
83
{
 
84
        static int i;
 
85
        static void TestMethod2 (int i)
 
86
        {
 
87
        }
 
88
}";
 
89
                        Test<ParameterHidesMemberIssue> (input, 1);
 
90
                }
 
91
                
 
92
                [Test]
 
93
                public void TestStaticNoIssue ()
 
94
                {
 
95
                        var input = @"
 
96
class TestClass
 
97
{
 
98
        static int i;
 
99
        int j;
 
100
        void TestMethod (int i)
 
101
        {
 
102
        }
 
103
        static void TestMethod2 (int j)
 
104
        {
 
105
        }
 
106
}";
 
107
                        Test<ParameterHidesMemberIssue> (input, 0);
 
108
                }
 
109
                
 
110
                [Test]
 
111
                public void TestAccessiblePrivate ()
 
112
                {
 
113
                        var input = @"
 
114
class TestClass
 
115
{
 
116
        int i;
 
117
 
 
118
        void Method (int i)
 
119
        {
 
120
        }
 
121
}";
 
122
                        Test<ParameterHidesMemberIssue> (input, 1);
 
123
                }
 
124
                
 
125
                [Test]
 
126
                public void TestAccessiblePrivateDueToTypeNesting ()
 
127
                {
 
128
                        var input = @"
 
129
class RootClass
 
130
{
 
131
        int i;
 
132
 
 
133
        class NestedClass : RootClass
 
134
        {
 
135
                // Issue 1
 
136
                void Method (int i) {}
 
137
 
 
138
                class NestedNestedClass : NestedClass
 
139
                {
 
140
                        // Issue 2
 
141
                        void OtherMethod (int i) {}
 
142
                }
 
143
        }
 
144
}";
 
145
                        Test<ParameterHidesMemberIssue> (input, 2);
 
146
                }
 
147
                
 
148
                [Test]
 
149
                public void TestInternalAccessibility ()
 
150
                {
 
151
                        var input = @"
 
152
class BaseClass
 
153
{
 
154
        internal int i;
 
155
}
 
156
class TestClass : BaseClass
 
157
{
 
158
        void Method (int i)
 
159
        {
 
160
        }
 
161
}";
 
162
                        Test<ParameterHidesMemberIssue> (input, 1);
 
163
                }
 
164
                
 
165
                [Test]
 
166
                public void TestInaccessiblePrivate ()
 
167
                {
 
168
                        var input = @"
 
169
class BaseClass
 
170
{
 
171
        private int i;
 
172
}
 
173
class TestClass : BaseClass
 
174
{
 
175
        void Method (int i)
 
176
        {
 
177
        }
 
178
}";
 
179
                        Test<ParameterHidesMemberIssue> (input, 0);
 
180
                }
 
181
        }
 
182
}