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

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/CreateChangedEventTests.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
// CreateChangedEventTests.cs
 
3
//
 
4
// Author:
 
5
//       Mike Krüger <mkrueger@xamarin.com>
 
6
//
 
7
// Copyright (c) 2013 Xamarin Inc. (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
using NUnit.Framework;
 
27
using ICSharpCode.NRefactory.CSharp.Refactoring;
 
28
 
 
29
namespace ICSharpCode.NRefactory.CSharp.CodeActions
 
30
{
 
31
        [TestFixture]
 
32
        public class CreateChangedEventTests : ContextActionTestBase
 
33
        {
 
34
                [Test]
 
35
                public void TestSimpleCase ()
 
36
                {
 
37
                        Test<CreateChangedEvent> (@"class TestClass
 
38
{
 
39
        string test;
 
40
        public string $Test {
 
41
                get {
 
42
                        return test;
 
43
                }
 
44
                set {
 
45
                        test = value;
 
46
                }
 
47
        }
 
48
}", @"class TestClass
 
49
{
 
50
        string test;
 
51
        public event System.EventHandler TestChanged;
 
52
        protected virtual void OnTestChanged (System.EventArgs e)
 
53
        {
 
54
                var handler = TestChanged;
 
55
                if (handler != null)
 
56
                        handler (this, e);
 
57
        }
 
58
        public string Test {
 
59
                get {
 
60
                        return test;
 
61
                }
 
62
                set {
 
63
                        test = value;
 
64
                        OnTestChanged (System.EventArgs.Empty);
 
65
                }
 
66
        }
 
67
}");
 
68
                }
 
69
 
 
70
                [Test]
 
71
                public void TestStaticClassCase ()
 
72
                {
 
73
                        Test<CreateChangedEvent> (@"static class TestClass
 
74
{
 
75
        static string test;
 
76
        public static string $Test {
 
77
                get {
 
78
                        return test;
 
79
                }
 
80
                set {
 
81
                        test = value;
 
82
                }
 
83
        }
 
84
}", @"static class TestClass
 
85
{
 
86
        static string test;
 
87
        public static event System.EventHandler TestChanged;
 
88
        static void OnTestChanged (System.EventArgs e)
 
89
        {
 
90
                var handler = TestChanged;
 
91
                if (handler != null)
 
92
                        handler (null, e);
 
93
        }
 
94
        public static string Test {
 
95
                get {
 
96
                        return test;
 
97
                }
 
98
                set {
 
99
                        test = value;
 
100
                        OnTestChanged (System.EventArgs.Empty);
 
101
                }
 
102
        }
 
103
}");
 
104
                }
 
105
        
 
106
                [Test]
 
107
                public void TestSealedCase ()
 
108
                {
 
109
                        Test<CreateChangedEvent> (@"sealed class TestClass
 
110
{
 
111
        string test;
 
112
        public string $Test {
 
113
                get {
 
114
                        return test;
 
115
                }
 
116
                set {
 
117
                        test = value;
 
118
                }
 
119
        }
 
120
}", @"sealed class TestClass
 
121
{
 
122
        string test;
 
123
        public event System.EventHandler TestChanged;
 
124
        void OnTestChanged (System.EventArgs e)
 
125
        {
 
126
                var handler = TestChanged;
 
127
                if (handler != null)
 
128
                        handler (this, e);
 
129
        }
 
130
        public string Test {
 
131
                get {
 
132
                        return test;
 
133
                }
 
134
                set {
 
135
                        test = value;
 
136
                        OnTestChanged (System.EventArgs.Empty);
 
137
                }
 
138
        }
 
139
}");
 
140
                }
 
141
 
 
142
        }
 
143
}
 
144