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

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/CreateConstructorDeclarationTests.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
// CreateClassActionTests.cs
 
3
//  
 
4
// Author:
 
5
//       Mike Krüger <mkrueger@xamarin.com>
 
6
// 
 
7
// Copyright (c) 2012 Xamarin <http://xamarin.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 System;
 
28
using NUnit.Framework;
 
29
using ICSharpCode.NRefactory.CSharp.Refactoring;
 
30
 
 
31
namespace ICSharpCode.NRefactory.CSharp.CodeActions
 
32
{
 
33
        [TestFixture]
 
34
        public class CreateConstructorDeclarationTests : ContextActionTestBase
 
35
        {
 
36
                [Test()]
 
37
                public void TestCreateConstructor ()
 
38
                {
 
39
                        Test<CreateConstructorDeclarationAction> (
 
40
@"
 
41
class Foo
 
42
{
 
43
}
 
44
 
 
45
class TestClass
 
46
{
 
47
        void TestMethod ()
 
48
        {
 
49
                $new Foo (0, ""Hello"");
 
50
        }
 
51
}
 
52
", @"
 
53
class Foo
 
54
{
 
55
        public Foo (int i, string hello)
 
56
        {
 
57
                throw new System.NotImplementedException ();
 
58
        }
 
59
}
 
60
 
 
61
class TestClass
 
62
{
 
63
        void TestMethod ()
 
64
        {
 
65
                new Foo (0, ""Hello"");
 
66
        }
 
67
}
 
68
");
 
69
                }
 
70
 
 
71
                [Test()]
 
72
                public void TestCreateConstructorInnerClass ()
 
73
                {
 
74
                        Test<CreateConstructorDeclarationAction> (
 
75
@"
 
76
class TestClass
 
77
{
 
78
        void TestMethod ()
 
79
        {
 
80
                $new Foo (0, ""Hello"");
 
81
        }
 
82
        class Foo
 
83
        {
 
84
        }
 
85
}
 
86
", @"
 
87
class TestClass
 
88
{
 
89
        void TestMethod ()
 
90
        {
 
91
                new Foo (0, ""Hello"");
 
92
        }
 
93
        class Foo
 
94
        {
 
95
        public Foo (int i, string hello)
 
96
        {
 
97
                throw new System.NotImplementedException ();
 
98
        }
 
99
        }
 
100
}
 
101
");
 
102
                }
 
103
 
 
104
                [Test()]
 
105
                public void TestCreateConstructorInStaticClass ()
 
106
                {
 
107
                        TestWrongContext<CreateConstructorDeclarationAction> (
 
108
@"
 
109
static class Foo
 
110
{
 
111
}
 
112
 
 
113
class TestClass
 
114
{
 
115
        void TestMethod ()
 
116
        {
 
117
                $new Foo (0, ""Hello"");
 
118
        }
 
119
}
 
120
");
 
121
                }
 
122
 
 
123
                [Test()]
 
124
                public void TestCreateConstructorInSealedClass ()
 
125
                {
 
126
                        TestWrongContext<CreateConstructorDeclarationAction> (
 
127
@"
 
128
sealed class Foo
 
129
{
 
130
}
 
131
 
 
132
class TestClass
 
133
{
 
134
        void TestMethod ()
 
135
        {
 
136
                $new Foo (0, ""Hello"");
 
137
        }
 
138
}
 
139
");
 
140
                }
 
141
 
 
142
                [Test()]
 
143
                public void TestCreateConstructorInFramework ()
 
144
                {
 
145
 
 
146
                        TestWrongContext<CreateConstructorDeclarationAction> (
 
147
@"
 
148
class TestClass
 
149
{
 
150
        void TestMethod ()
 
151
        {
 
152
                $new System.NotImplementedException (0, ""Hello"", new TestClass ());
 
153
        }
 
154
}
 
155
");
 
156
                }
 
157
 
 
158
                [Test]
 
159
                public void TestBug9664  ()
 
160
                {
 
161
                        TestWrongContext<CreateConstructorDeclarationAction> (
 
162
                                @"enum Foo
 
163
{
 
164
    Bar,
 
165
}
 
166
 
 
167
class Baz
 
168
{
 
169
    public Baz (Foo foo)
 
170
    {
 
171
    }
 
172
}
 
173
 
 
174
class Program
 
175
{
 
176
    public void Main ()
 
177
    {
 
178
        var b = new Baz (Foo.$Something);
 
179
    }
 
180
}
 
181
");
 
182
                }
 
183
        }
 
184
}