Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MemberTests.cs « MonoDevelop.CSharpBinding « UnitTests « tests « main - github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5db91c48e7afd7e7ac26eea2bcd9eb777764a38c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
////
//// MemberTests.cs
////
//// Author:
////   Mike Krüger <mkrueger@novell.com>
////
//// Copyright (C) 2008 Novell, Inc (http://www.novell.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 System.Collections.Generic;
//
//using NUnit.Framework;
//using MonoDevelop.CSharpBinding;
//using MonoDevelop.CSharp.Parser;
//
//namespace MonoDevelop.CSharpBinding.Tests
//{
//	[TestFixture]
//	public class MemberTests
//	{
//		void DoTestFields (IParser parser)
//		{
//			ICompilationUnit unit = parser.Parse (null, "a.cs", @"class AClass { int x, y; }").CompilationUnit;
//			Assert.AreEqual (1, unit.Types.Count);
//			IType type = unit.Types[0];
//			
//			Assert.AreEqual (2, type.FieldCount);
//			List<IField> fields = new List<IField> (type.Fields);
//			Assert.AreEqual ("x", fields[0].Name);
//			Assert.AreEqual ("System.Int32", fields[0].ReturnType.FullName);
//			Assert.AreEqual ("y", fields[1].Name);
//			Assert.AreEqual ("System.Int32", fields[1].ReturnType.FullName);
//		}
//		
//		[Test]
//		public void TestFields ()
//		{
//			DoTestFields (new McsParser ());
////			DoTestFields (new DomParser ());
//		}
//		
//		void DoTestMethods (IParser parser)
//		{
//			ICompilationUnit unit = parser.Parse (null, "a.cs", 
//@"class AClass {
//     void TestMethod<T> (string a, int b) {}
//     public static void ExtensionMethod (this int a) {}; 
//}").CompilationUnit;
//			Assert.AreEqual (1, unit.Types.Count);
//			IType type = unit.Types[0];
//			
//			Assert.AreEqual (2, type.MethodCount);
//			List<IMethod> methods = new List<IMethod> (type.Methods);
//			Assert.AreEqual ("TestMethod", methods[0].Name);
//			Assert.AreEqual (2, methods[0].Parameters.Count);
//			Assert.AreEqual ("a", methods[0].Parameters[0].Name);
//			Assert.AreEqual ("b", methods[0].Parameters[1].Name);
//						
//			Assert.IsFalse (methods[1].IsConstructor);
//			Assert.IsTrue (methods[1].IsExtension);
//			Assert.AreEqual (1, methods[1].Parameters.Count);
//			Assert.AreEqual ("a", methods[1].Parameters[0].Name);
//		}
//		
//		[Test]
//		public void TestMethods ()
//		{
//			DoTestMethods (new McsParser ());
////			DoTestMethods (new DomParser ());
//		}
//		
//		void DoTestConstructor (IParser parser)
//		{
//			ICompilationUnit unit = parser.Parse (null, "a.cs", 
//@"public abstract class BaseClass {
//     BaseClass () {}
//  	protected BaseClass(int id)
//    {
//    }     
//}").CompilationUnit;
//			Assert.AreEqual (1, unit.Types.Count);
//			IType type = unit.Types[0];
//			
//			Assert.AreEqual (2, type.ConstructorCount);
//			List<IMethod> methods = new List<IMethod> (type.Methods);
//			Assert.IsTrue (methods[0].IsConstructor);
//			Assert.IsTrue (methods[1].IsConstructor);
//		}
//		
//		[Test]
//		public void TestConstructor ()
//		{
//			DoTestConstructor (new McsParser ());
////			DoTestConstructor (new DomParser ());
//		}
//		
//		void DoTestProperties (IParser parser)
//		{
//			ICompilationUnit unit = parser.Parse (null, "a.cs", 
//@"class AClass {
//	int MyProperty {
//		get { }
//		set { }
//	}
//	string MyProperty2 {
//		set { }
//	}
//	string MyProperty3 {
//		get { }
//	}
//}").CompilationUnit;
//			Assert.AreEqual (1, unit.Types.Count);
//			IType type = unit.Types[0];
//			
//			Assert.AreEqual (3, type.PropertyCount);
//			List<IProperty> properties = new List<IProperty> (type.Properties);
//			Assert.AreEqual ("MyProperty", properties[0].Name);
//			Assert.IsTrue (properties[0].HasGet);
//			Assert.IsTrue (properties[0].HasSet);
//			Assert.IsFalse (properties[0].IsIndexer);
//			
//			Assert.AreEqual ("MyProperty2", properties[1].Name);
//			Assert.IsFalse (properties[1].HasGet);
//			Assert.IsTrue (properties[1].HasSet);
//			Assert.IsFalse (properties[1].IsIndexer);
//			
//			Assert.AreEqual ("MyProperty3", properties[2].Name);
//			Assert.IsTrue (properties[2].HasGet);
//			Assert.IsFalse (properties[2].HasSet);
//			Assert.IsFalse (properties[2].IsIndexer);
//		}
//		
//		[Test]
//		public void TestProperties ()
//		{
//			DoTestProperties (new McsParser ());
////			DoTestProperties (new DomParser ());
//		}
//		
//		void DoTestIndexer (IParser parser)
//		{
//			ICompilationUnit unit = parser.Parse (null, "a.cs", 
//@"class AClass {
//	int this[int a] {
//		get { }
//		set { }
//	}
//}").CompilationUnit;
//			Assert.AreEqual (1, unit.Types.Count);
//			IType type = unit.Types[0];
//			
//			Assert.AreEqual (1, type.IndexerCount);
//			List<IProperty> properties = new List<IProperty> (type.Properties);
//			Assert.IsTrue (properties[0].IsIndexer);
//			Assert.AreEqual (1, properties[0].Parameters.Count);
//			Assert.AreEqual ("a", properties[0].Parameters[0].Name);
//		}
//		
//		[Test]
//		public void TestIndexer ()
//		{
//			DoTestIndexer (new McsParser ());
////			DoTestIndexer (new DomParser ());
//		}
//
//		void DoTestEvents (IParser parser)
//		{
//			ICompilationUnit unit = parser.Parse (null, "a.cs", 
//@"class AClass {
//	event EventHandler TestEvent;
//}").CompilationUnit;
//			Assert.AreEqual (1, unit.Types.Count);
//			IType type = unit.Types[0];
//			
//			Assert.AreEqual (1, type.EventCount);
//			List<IEvent> events = new List<IEvent> (type.Events);
//			Assert.AreEqual ("TestEvent", events[0].Name);
//			Assert.AreEqual ("EventHandler", events[0].ReturnType.Name);
//		}
//		
//		[Test]
//		public void TestEvents ()
//		{
//			DoTestEvents (new McsParser ());
////			DoTestEvents (new DomParser ());
//		}
//		
//	}
//}