Merge pull request #2346 from xmcclure/proxy-load-fail
[mono.git] / mcs / class / System / Test / Microsoft.VisualBasic / CodeGeneratorFromTypeTest.cs
1 //
2 // Microsoft.VisualBasic.* Test Cases
3 //
4 // Authors:
5 // Gert Driesen (drieseng@users.sourceforge.net)
6 //
7 // (c) Novell
8 //
9
10 using System;
11 using System.CodeDom;
12 using System.CodeDom.Compiler;
13 using System.Globalization;
14
15 using Microsoft.VisualBasic;
16
17 using NUnit.Framework;
18
19 using MonoTests.System.CodeDom.Compiler;
20
21 namespace MonoTests.Microsoft.VisualBasic
22 {
23         [TestFixture]
24         public class CodeGeneratorFromTypeTest_Class : CodeGeneratorFromTypeTestBase
25         {
26                 private CodeTypeDeclaration _typeDeclaration;
27                 private ICodeGenerator _codeGenerator;
28
29                 protected override ICodeGenerator CodeGenerator
30                 {
31                         get { return _codeGenerator; }
32                 }
33
34                 protected override CodeTypeDeclaration TypeDeclaration
35                 {
36                         get { return _typeDeclaration; }
37                 }
38
39                 [SetUp]
40                 public override void SetUp ()
41                 {
42                         base.SetUp ();
43                         _typeDeclaration = new CodeTypeDeclaration ();
44
45                         CodeDomProvider provider = new VBCodeProvider ();
46                         _codeGenerator = provider.CreateGenerator ();
47                 }
48
49                 [Test]
50                 public override void DefaultTypeTest ()
51                 {
52                         string code = GenerateDefaultType (Options);
53                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
54                                 "Public Class {0}" +
55                                 "End Class{0}", NewLine), code);
56                 }
57
58                 [Test]
59                 [ExpectedException (typeof (NullReferenceException))]
60                 public override void NullTypeTest ()
61                 {
62                         GenerateNullType (Options);
63                 }
64
65                 [Test]
66                 public override void SimpleTypeTest ()
67                 {
68                         string code = GenerateSimpleType (Options);
69                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
70                                 "Public Class Test1{0}" +
71                                 "End Class{0}", NewLine), code);
72                 }
73
74                 [Test]
75                 public override void DerivedTypeTest ()
76                 {
77                         string code = GenerateDerivedType (Options);
78                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
79                                 "Friend MustInherit Class Test1{0}" +
80                                 "    Inherits Integer{0}" +
81                                 "    Implements System.Security.Principal.IIdentity, String, System.Security.IPermission{0}" +
82                                 "End Class{0}", NewLine), code);
83                 }
84
85                 [Test]
86                 public override void AttributesAndTypeTest ()
87                 {
88                         string code = GenerateAttributesAndType (Options);
89                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
90                                 "<A(),  _{0}" +
91                                 " B()>  _{0}" +
92                                 "Public Class Test1{0}" +
93                                 "End Class{0}", NewLine), code);
94                 }
95
96                 [Test]
97                 public override void EventMembersTypeTest1 ()
98                 {
99                         string code = GenerateEventMembersType1 (Options);
100                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
101                                 "Public Class Test1{0}" +
102                                 "    {0}" +
103                                 "    <A(),  _{0}" +
104                                 "     B()>  _{0}" +
105                                 "    Private Event __exception As System.Void{0}" +
106                                 "End Class{0}", NewLine), code);
107                 }
108
109                 [Test]
110                 public override void EventMembersTypeTest2 ()
111                 {
112                         string code = GenerateEventMembersType2 (Options);
113                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
114                                 "Public Class Test1{0}" +
115                                 "    {0}" +
116                                 "    Public Event Click As Integer{0}" +
117                                 "End Class{0}", NewLine), code);
118                 }
119
120                 [Test]
121                 public override void EventImplementationTypes ()
122                 {
123                         string code = GenerateEventImplementationTypes (Options);
124                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
125                                 "Public Class Test1{0}" +
126                                 "    {0}" +
127                                 "    Friend Event Click As Integer Implements IPolicy.Click , IWhatever.Click{0}" +
128                                 "End Class{0}", NewLine), code);
129                 }
130
131                 /// <summary>
132                 /// Ensure no access modifiers are output if PrivateImplementationType
133                 /// is set.
134                 /// </summary>
135                 [Test]
136                 public override void EventPrivateImplementationType ()
137                 {
138                         string code = GenerateEventPrivateImplementationType (Options);
139                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
140                                 "Public Class Test1{0}" +
141                                 "    {0}" +
142                                 "    Protected Event System_Int32_Click As Integer Implements Integer.Click{0}" +
143                                 "End Class{0}", NewLine), code);
144                 }
145
146                 /// <summary>
147                 /// If both ImplementationTypes and PrivateImplementationType are set,
148                 /// then only ImplementationTypes are output.
149                 /// </summary>
150                 [Test]
151                 public override void EventImplementationTypeOrder ()
152                 {
153                         string code = GenerateEventImplementationTypeOrder (Options);
154                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
155                                 "Public Class Test1{0}" +
156                                 "    {0}" +
157                                 "    Public Event System_Int32_Click As Integer Implements IPolicy.Click{0}" +
158                                 "End Class{0}", NewLine), code);
159                 }
160
161                 [Test]
162                 public override void FieldMembersAttributesTest ()
163                 {
164                         string code = GenerateFieldMembersAttributes (Options);
165                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
166                                 "Public Class Test1{0}" +
167                                 "    {0}" +
168                                 "    <A(),  _{0}" +
169                                 "     B()>  _{0}" +
170                                 "    Private __exception As System.Void{0}" +
171                                 "End Class{0}", NewLine), code);
172                 }
173
174                 [Test]
175                 public override void FieldMembersTypeTest ()
176                 {
177                         string code = GenerateFieldMembersType (MemberAttributes.Public, Options);
178                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
179                                 "Public Class Test1{0}" +
180                                 "    {0}" +
181                                 "    Public Name As Integer = 2{0}" +
182                                 "End Class{0}", NewLine), code);
183                 }
184
185                 [Test]
186                 public override void FieldNewSlotTest ()
187                 {
188                         string code = GenerateFieldMembersType (MemberAttributes.Assembly |
189                                 MemberAttributes.New, Options);
190                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
191                                 "Public Class Test1{0}" +
192                                 "    {0}" +
193                                 "    Friend Shadows Name As Integer = 2{0}" +
194                                 "End Class{0}", NewLine), code);
195                 }
196
197                 [Test]
198                 public void AbstractPropertyTest ()
199                 {
200                         string code = GenerateAbstractProperty (Options);
201                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
202                                 "Public MustInherit Class Test1{0}" +
203                                 "    {0}" +
204                                 "    Public MustOverride Property Name() As String{0}" +
205                                 "        Get{0}" +
206                                 "        Set{0}" +
207                                 "    End Property{0}" +
208                                 "End Class{0}", NewLine), code);
209                 }
210
211                 [Test]
212                 public void StaticPropertyTest ()
213                 {
214                         string code = GenerateStaticProperty (Options);
215                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
216                                 "Public Class Test1{0}" +
217                                 "    {0}" +
218                                 "    Public Shared WriteOnly Property Name() As String{0}" +
219                                 "        Set{0}" +
220                                 "        End Set{0}" +
221                                 "    End Property{0}" +
222                                 "End Class{0}", NewLine), code);
223                 }
224
225                 [Test]
226                 public override void PropertyMembersTypeTest1 ()
227                 {
228                         string code = GeneratePropertyMembersAttributes (Options);
229                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
230                                 "Public Class Test1{0}" +
231                                 "    {0}" +
232                                 "    <A(),  _{0}" +
233                                 "     B()>  _{0}" +
234                                 "    Private Property () As System.Void{0}" +
235                                 "    End Property{0}" +
236                                 "End Class{0}", NewLine), code);
237                 }
238
239                 [Test]
240                 public override void PropertyMembersTypeTest2 ()
241                 {
242                         string code = GeneratePropertyMembersType (MemberAttributes.Public,
243                                 false, false, Options);
244                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
245                                 "Public Class Test1{0}" +
246                                 "    {0}" +
247                                 "    Public Overridable Property Name() As Integer{0}" +
248                                 "    End Property{0}" +
249                                 "End Class{0}", NewLine), code);
250                 }
251
252                 [Test]
253                 public override void PropertyMembersTypeGetOnly ()
254                 {
255                         string code = GeneratePropertyMembersType (MemberAttributes.Family,
256                                 true, false, Options);
257                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
258                                 "Public Class Test1{0}" +
259                                 "    {0}" +
260                                 "    Protected Overridable ReadOnly Property Name() As Integer{0}" +
261                                 "        Get{0}" +
262                                 "        End Get{0}" +
263                                 "    End Property{0}" +
264                                 "End Class{0}", NewLine), code);
265                 }
266
267                 [Test]
268                 public override void PropertyMembersTypeSetOnly ()
269                 {
270                         string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
271                                 false, true, Options);
272                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
273                                 "Public Class Test1{0}" +
274                                 "    {0}" +
275                                 "    Friend Overridable WriteOnly Property Name() As Integer{0}" +
276                                 "        Set{0}" +
277                                 "        End Set{0}" +
278                                 "    End Property{0}" +
279                                 "End Class{0}", NewLine), code);
280                 }
281
282                 [Test]
283                 public override void PropertyMembersTypeGetSet ()
284                 {
285                         string code = GeneratePropertyMembersType (MemberAttributes.Family,
286                                 true, true, Options);
287                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
288                                 "Public Class Test1{0}" +
289                                 "    {0}" +
290                                 "    Protected Overridable Property Name() As Integer{0}" +
291                                 "        Get{0}" +
292                                 "        End Get{0}" +
293                                 "        Set{0}" +
294                                 "        End Set{0}" +
295                                 "    End Property{0}" +
296                                 "End Class{0}", NewLine), code);
297                 }
298
299                 [Test]
300                 public override void PropertyMembersTypeFamilyOrAssembly ()
301                 {
302                         string code = GeneratePropertyMembersType (MemberAttributes.FamilyOrAssembly,
303                                 false, false, Options);
304                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
305                                 "Public Class Test1{0}" +
306                                 "    {0}" +
307                                 "    Protected Friend Property Name() As Integer{0}" +
308                                 "    End Property{0}" +
309                                 "End Class{0}", NewLine), code);
310                 }
311
312                 [Test]
313                 public override void PropertyMembersTypeAssembly ()
314                 {
315                         string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
316                                 false, false, Options);
317                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
318                                 "Public Class Test1{0}" +
319                                 "    {0}" +
320                                 "    Friend Overridable Property Name() As Integer{0}" +
321                                 "    End Property{0}" +
322                                 "End Class{0}", NewLine), code);
323                 }
324
325                 /// <summary>
326                 /// Apparently VB.NET CodeDOM also allows properties that aren't indexers
327                 /// to have parameters.
328                 /// </summary>
329                 [Test]
330                 public override void PropertyParametersTest ()
331                 {
332                         string code = GeneratePropertyParameters (Options);
333                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
334                                 "Public Class Test1{0}" +
335                                 "    {0}" +
336                                 "    Public Overridable Property Name(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
337                                 "    End Property{0}" +
338                                 "End Class{0}", NewLine), code);
339                 }
340
341                 [Test]
342                 public override void PropertyIndexerTest1 ()
343                 {
344                         string code = GeneratePropertyIndexer (MemberAttributes.Public,
345                                 false, false, true, Options);
346                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
347                                 "Public Class Test1{0}" +
348                                 "    {0}" +
349                                 "    Public Overridable Default Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
350                                 "    End Property{0}" +
351                                 "End Class{0}", NewLine), code);
352                 }
353
354                 /// <summary>
355                 /// Ensures Default keyword is only output if property is named "Item"
356                 /// (case-insensitive comparison) AND parameters are defined.
357                 /// </summary>
358                 [Test]
359                 public override void PropertyIndexerTest2 ()
360                 {
361                         string code = GeneratePropertyIndexer (MemberAttributes.Public,
362                                 false, false, false, Options);
363                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
364                                 "Public Class Test1{0}" +
365                                 "    {0}" +
366                                 "    Public Overridable Property iTem() As Integer{0}" +
367                                 "    End Property{0}" +
368                                 "End Class{0}", NewLine), code);
369                 }
370
371                 /// <summary>
372                 /// Ensures Default keyword is output after ReadOnly modifier.
373                 /// </summary>
374                 [Test]
375                 public override void PropertyIndexerGetOnly ()
376                 {
377                         string code = GeneratePropertyIndexer (MemberAttributes.Family,
378                                 true, false, true, Options);
379                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
380                                 "Public Class Test1{0}" +
381                                 "    {0}" +
382                                 "    Protected Overridable Default ReadOnly Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
383                                 "        Get{0}" +
384                                 "        End Get{0}" +
385                                 "    End Property{0}" +
386                                 "End Class{0}", NewLine), code);
387                 }
388
389                 /// <summary>
390                 /// Ensures Default keyword is output after WriteOnly modifier.
391                 /// </summary>
392                 [Test]
393                 public override void PropertyIndexerSetOnly ()
394                 {
395                         string code = GeneratePropertyIndexer (MemberAttributes.Family,
396                                 false, true, true, Options);
397                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
398                                 "Public Class Test1{0}" +
399                                 "    {0}" +
400                                 "    Protected Overridable Default WriteOnly Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
401                                 "        Set{0}" +
402                                 "        End Set{0}" +
403                                 "    End Property{0}" +
404                                 "End Class{0}", NewLine), code);
405                 }
406
407                 [Test]
408                 public override void PropertyImplementationTypes ()
409                 {
410                         string code = GeneratePropertyImplementationTypes (Options);
411                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
412                                 "Public Class Test1{0}" +
413                                 "    {0}" +
414                                 "    Public Overridable Property Name() As Integer Implements IPolicy.Name , IWhatever.Name{0}" +
415                                 "    End Property{0}" +
416                                 "End Class{0}", NewLine), code);
417                 }
418
419                 /// <summary>
420                 /// Ensure that Overloads keyword is output for a property which has
421                 /// explicitly been marked as Overloaded.
422                 /// </summary>
423                 [Test]
424                 public override void PropertyOverloadsTest1 ()
425                 {
426                         string code = GeneratePropertyOverloads1 (Options);
427                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
428                                 "Public Class Test1{0}" +
429                                 "    {0}" +
430                                 "    Protected Overloads Overridable Property Name() As Integer{0}" +
431                                 "    End Property{0}" +
432                                 "End Class{0}", NewLine), code);
433                 }
434
435                 /// <summary>
436                 /// Ensure that Overloads keyword is output if multiple properties with
437                 /// the same name are defined.
438                 /// </summary>
439                 [Test]
440                 public override void PropertyOverloadsTest2 ()
441                 {
442                         string code = GeneratePropertyOverloads2 (Options);
443                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
444                                 "Public Class Test1{0}" +
445                                 "    {0}" +
446                                 "    Public Overloads Overridable Property Name() As Integer{0}" +
447                                 "    End Property{0}" +
448                                 "    {0}" +
449                                 "    Private Overloads Property Name(ByVal value1 As Object) As Integer{0}" +
450                                 "    End Property{0}" +
451                                 "End Class{0}", NewLine), code);
452                 }
453
454                 /// <summary>
455                 /// Ensure that a property with a PrivateImplementationType and with 
456                 /// the same name does not qualify as an overload.
457                 /// </summary>
458                 [Test]
459                 public override void PropertyOverloadsTest3 ()
460                 {
461                         string code = GeneratePropertyOverloads3 (Options);
462                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
463                                 "Public Class Test1{0}" +
464                                 "    {0}" +
465                                 "    Public Overridable Property Name() As Integer{0}" +
466                                 "    End Property{0}" +
467                                 "    {0}" +
468                                 "    Property System_Int32_Name(ByVal value1 As Object) As Integer Implements Integer.Name{0}" +
469                                 "    End Property{0}" +
470                                 "End Class{0}", NewLine), code);
471                 }
472
473                 /// <summary>
474                 /// Ensure no access modifiers are output if PrivateImplementationType
475                 /// is set. Default keyword is also not output in this case.
476                 /// </summary>
477                 [Test]
478                 public override void PropertyPrivateImplementationType ()
479                 {
480                         string code = GeneratePropertyPrivateImplementationType (Options);
481                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
482                                 "Public Class Test1{0}" +
483                                 "    {0}" +
484                                 "    Overridable Property System_Int32_Item(ByVal value1 As Object) As Integer Implements Integer.Item{0}" +
485                                 "    End Property{0}" +
486                                 "End Class{0}", NewLine), code);
487                 }
488
489                 /// <summary>
490                 /// If both ImplementationTypes and PrivateImplementationType are set,
491                 /// then only ImplementationTypes are output.
492                 /// </summary>
493                 [Test]
494                 public override void PropertyImplementationTypeOrder ()
495                 {
496                         string code = GeneratePropertyImplementationTypeOrder (Options);
497                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
498                                 "Public Class Test1{0}" +
499                                 "    {0}" +
500                                 "    Overridable Property System_Int32_Item(ByVal value1 As Object) As Integer Implements IPolicy.Item{0}" +
501                                 "    End Property{0}" +
502                                 "End Class{0}", NewLine), code);
503                 }
504
505                 [Test]
506                 public override void PropertyNewSlotTest ()
507                 {
508                         string code = GeneratePropertyMembersType (MemberAttributes.Private |
509                                 MemberAttributes.New, true, true, Options);
510                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
511                                 "Public Class Test1{0}" +
512                                 "    {0}" +
513                                 "    Private Shadows Property Name() As Integer{0}" +
514                                 "        Get{0}" +
515                                 "        End Get{0}" +
516                                 "        Set{0}" +
517                                 "        End Set{0}" +
518                                 "    End Property{0}" +
519                                 "End Class{0}", NewLine), code);
520                 }
521
522                 [Test]
523                 public override void MethodMembersTypeTest1 ()
524                 {
525                         string code = GenerateMethodMembersType1 (Options);
526                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
527                                 "Public Class Test1{0}" +
528                                 "    {0}" +
529                                 "    <A(),  _{0}" +
530                                 "     B()>  _{0}" +
531                                 "    Private Sub (){0}" +
532                                 "    End Sub{0}" +
533                                 "End Class{0}", NewLine), code);
534                 }
535
536                 [Test]
537                 public override void MethodMembersTypeTest2 ()
538                 {
539                         string code = GenerateMethodMembersType2 (Options);
540                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
541                                 "Public Class Test1{0}" +
542                                 "    {0}" +
543                                 "    Public Overridable Function Something(ByVal value1 As Object, ByVal value2 As Object, ByRef index As Integer, ByRef count As Integer) As Integer{0}" +
544                                 "    End Function{0}" +
545                                 "End Class{0}", NewLine), code);
546                 }
547
548                 [Test]
549                 public override void MethodMembersTypeTest3 ()
550                 {
551                         string code = GenerateMethodMembersType3 (Options);
552                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
553                                 "Public Class Test1{0}" +
554                                 "    {0}" +
555                                 "    Public Overridable Function Something(<A(), B()> ByVal value As Object, <C(A1:=false, A2:=true), D()> ByRef __exception As Integer) As Integer{0}" +
556                                 "    End Function{0}" +
557                                 "End Class{0}", NewLine), code);
558                 }
559
560                 [Test]
561                 public override void MethodImplementationTypes ()
562                 {
563                         string code = GenerateMethodImplementationTypes (Options);
564                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
565                                 "Public Class Test1{0}" +
566                                 "    {0}" +
567                                 "    Friend Overridable Function Execute() As Integer Implements IPolicy.Execute , IWhatever.Execute{0}" +
568                                 "    End Function{0}" +
569                                 "End Class{0}", NewLine), code);
570                 }
571
572                 /// <summary>
573                 /// Ensure that Overloads keyword is output for a method which has
574                 /// explicitly been marked as Overloaded.
575                 /// </summary>
576                 [Test]
577                 public override void MethodOverloadsTest1 ()
578                 {
579                         string code = GenerateMethodOverloads1 (Options);
580                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
581                                 "Public Class Test1{0}" +
582                                 "    {0}" +
583                                 "    Friend Overloads Overridable Function Execute() As Integer{0}" +
584                                 "    End Function{0}" +
585                                 "End Class{0}", NewLine), code);
586                 }
587
588                 /// <summary>
589                 /// Ensure that Overloads keyword is output if multiple methods with
590                 /// the same name are defined.
591                 /// </summary>
592                 [Test]
593                 public override void MethodOverloadsTest2 ()
594                 {
595                         string code = GenerateMethodOverloads2 (Options);
596                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
597                                 "Public Class Test1{0}" +
598                                 "    {0}" +
599                                 "    Public Overloads Overridable Sub Execute(){0}" +
600                                 "    End Sub{0}" +
601                                 "    {0}" +
602                                 "    Private Overloads Function Execute(ByVal value1 As Object) As Integer{0}" +
603                                 "    End Function{0}" +
604                                 "End Class{0}", NewLine), code);
605                 }
606
607                 /// <summary>
608                 /// Ensure that a method with a PrivateImplementationType and with 
609                 /// the same name does not qualify as an overload.
610                 /// </summary>
611                 [Test]
612                 public override void MethodOverloadsTest3 ()
613                 {
614                         string code = GenerateMethodOverloads3 (Options);
615                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
616                                 "Public Class Test1{0}" +
617                                 "    {0}" +
618                                 "    Public Overridable Sub Execute(){0}" +
619                                 "    End Sub{0}" +
620                                 "    {0}" +
621                                 "    Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements Integer.Execute{0}" +
622                                 "    End Function{0}" +
623                                 "End Class{0}", NewLine), code);
624                 }
625
626                 /// <summary>
627                 /// Ensure no access modifiers are output if PrivateImplementationType
628                 /// is set.
629                 /// </summary>
630                 [Test]
631                 public override void MethodPrivateImplementationType ()
632                 {
633                         string code = GenerateMethodPrivateImplementationType (Options);
634                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
635                                 "Public Class Test1{0}" +
636                                 "    {0}" +
637                                 "    Overridable Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements Integer.Execute{0}" +
638                                 "    End Function{0}" +
639                                 "End Class{0}", NewLine), code);
640                 }
641
642                 /// <summary>
643                 /// If both ImplementationTypes and PrivateImplementationType are set,
644                 /// then only ImplementationTypes are output.
645                 /// </summary>
646                 [Test]
647                 public override void MethodImplementationTypeOrder ()
648                 {
649                         string code = GenerateMethodImplementationTypeOrder (Options);
650                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
651                                 "Public Class Test1{0}" +
652                                 "    {0}" +
653                                 "    Overridable Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements IPolicy.Execute{0}" +
654                                 "    End Function{0}" +
655                                 "End Class{0}", NewLine), code);
656                 }
657
658                 [Test]
659                 public override void MethodParamArrayAttribute ()
660                 {
661                         string code = GenerateMethodParamArrayAttribute (Options);
662                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
663                                 "Public Class Test1{0}" +
664                                 "    {0}" +
665                                 "    Public Overridable Function Something(<A(), System.ParamArrayAttribute(), B()> ByRef value As Object, <C()> ByRef __exception As Integer) As Integer{0}" +
666                                 "    End Function{0}" +
667                                 "End Class{0}", NewLine), code);
668                 }
669
670                 [Test]
671                 public override void MethodReturnTypeAttributes ()
672                 {
673                         string code = GenerateMethodReturnTypeAttributes (Options);
674                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
675                                 "Public Class Test1{0}" +
676                                 "    {0}" +
677                                 "    <A(),  _{0}" +
678                                 "     B(),  _{0}" +
679                                 "     System.ParamArrayAttribute()>  _{0}" +
680                                 "    Public Overridable Function Execute() As <C(A1:=false, A2:=true), System.ParamArrayAttribute(), D()> Integer{0}" +
681                                 "    End Function{0}" +
682                                 "End Class{0}", NewLine), code);
683                 }
684
685                 [Test]
686                 public override void MethodNewSlotTest ()
687                 {
688                         string code = GenerateMethodNewSlot (Options);
689                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
690                                 "Public Class Test1{0}" +
691                                 "    {0}" +
692                                 "    Public Shadows Overridable Function Execute() As Integer{0}" +
693                                 "    End Function{0}" +
694                                 "End Class{0}", NewLine), code);
695                 }
696
697                 [Test]
698                 public override void ConstructorAttributesTest ()
699                 {
700                         // FIXME: updated to reflect mbas workaround
701                         string code = GenerateConstructorAttributes (Options);
702                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
703                                 "Public Class Test1{0}" +
704                                 "    {0}" +
705                                 "    <A(),  _{0}" +
706                                 "     B()>  _{0}" +
707                                 "    Private Sub New(){0}" +
708                                 "        MyBase.New{0}" +
709                                 "    End Sub{0}" +
710                                 "End Class{0}", NewLine), code);
711                 }
712
713                 [Test]
714                 public override void ConstructorParametersTest ()
715                 {
716                         // FIXME: updated to reflect mbas workaround
717                         string code = GenerateConstructorParameters (Options);
718                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
719                                 "Public Class Test1{0}" +
720                                 "    {0}" +
721                                 "    Public Sub New(ByVal value1 As Object, ByVal value2 As Object, ByRef index As Integer, ByRef count As Integer){0}" +
722                                 "        MyBase.New{0}" +
723                                 "    End Sub{0}" +
724                                 "End Class{0}", NewLine), code);
725                 }
726
727                 [Test]
728                 public override void ConstructorParameterAttributesTest ()
729                 {
730                         // FIXME: updated to reflect mbas workaround
731                         string code = GenerateConstructorParameterAttributes (Options);
732                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
733                                 "Public Class Test1{0}" +
734                                 "    {0}" +
735                                 "    Private Sub New(<A(), B()> ByVal value As Object, <C(A1:=false, A2:=true), D()> ByRef index As Integer){0}" +
736                                 "        MyBase.New{0}" +
737                                 "    End Sub{0}" +
738                                 "End Class{0}", NewLine), code);
739                 }
740
741                 [Test]
742                 public override void BaseConstructorSingleArg ()
743                 {
744                         string code = GenerateBaseConstructor (false, Options);
745                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
746                                 "Public Class Test1{0}" +
747                                 "    {0}" +
748                                 "    Protected Sub New(ByVal value1 As Object, ByRef value2 As Integer){0}" +
749                                 "        MyBase.New(value1){0}" +
750                                 "    End Sub{0}" +
751                                 "End Class{0}", NewLine), code);
752                 }
753
754                 [Test]
755                 public override void BaseConstructorMultipleArgs ()
756                 {
757                         string code = GenerateBaseConstructor (true, Options);
758                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
759                                 "Public Class Test1{0}" +
760                                 "    {0}" +
761                                 "    Protected Sub New(ByVal value1 As Object, ByRef value2 As Integer){0}" +
762                                 "        MyBase.New(value1, value2){0}" +
763                                 "    End Sub{0}" +
764                                 "End Class{0}", NewLine), code);
765                 }
766
767                 [Test]
768                 public override void ChainedConstructorSingleArg ()
769                 {
770                         string code = GenerateChainedConstructor (false, Options);
771                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
772                                 "Public Class Test1{0}" +
773                                 "    {0}" +
774                                 "    Public Sub New(ByVal value1 As Object, ByRef value2 As Integer){0}" +
775                                 "        Me.New(value1){0}" +
776                                 "    End Sub{0}" +
777                                 "End Class{0}", NewLine), code);
778                 }
779
780                 [Test]
781                 public override void ChainedConstructorMultipleArgs ()
782                 {
783                         string code = GenerateChainedConstructor (true, Options);
784                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
785                                 "Public Class Test1{0}" +
786                                 "    {0}" +
787                                 "    Public Sub New(ByVal value1 As Object, ByRef value2 As Integer){0}" +
788                                 "        Me.New(value1, value2){0}" +
789                                 "    End Sub{0}" +
790                                 "End Class{0}", NewLine), code);
791                 }
792
793                 [Test]
794                 public override void TypeConstructorTest ()
795                 {
796                         string code = GenerateTypeConstructor (Options);
797                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
798                                 "Public Class Test1{0}" +
799                                 "    {0}" +
800                                 "    <A(),  _{0}" +
801                                 "     B()>  _{0}" +
802                                 "    Shared Sub New(){0}" +
803                                 "    End Sub{0}" +
804                                 "End Class{0}", NewLine), code);
805                 }
806
807                 [Test]
808                 public override void EntryPointMethodTest ()
809                 {
810                         string code = GenerateEntryPointMethod (Options);
811                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
812                                 "Public Class Test1{0}" +
813                                 "    {0}" +
814                                 "    <A()>  _{0}" +
815                                 "    Public Shared Sub Main(){0}" +
816                                 "        Dim x As Test.InnerType{0}" +
817                                 "    End Sub{0}" +
818                                 "End Class{0}", NewLine), code);
819                 }
820                 
821                 [Test]
822                 public override void PartialTypeTest ()
823                 {
824                         string code = GeneratePartialType (Options);
825                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
826                                 "Partial Public Class Test1{0}" +
827                                 "End Class{0}", NewLine), code);
828                 }
829         }
830
831         [TestFixture]
832         public class CodeGeneratorFromTypeTest_Delegate : CodeGeneratorFromTypeTestBase
833         {
834                 private CodeTypeDeclaration _typeDeclaration;
835                 private ICodeGenerator _codeGenerator;
836
837                 protected override ICodeGenerator CodeGenerator
838                 {
839                         get { return _codeGenerator; }
840                 }
841
842                 protected override CodeTypeDeclaration TypeDeclaration
843                 {
844                         get { return _typeDeclaration; }
845                 }
846
847                 [SetUp]
848                 public override void SetUp ()
849                 {
850                         base.SetUp ();
851                         _typeDeclaration = new CodeTypeDelegate ();
852
853                         CodeDomProvider provider = new VBCodeProvider ();
854                         _codeGenerator = provider.CreateGenerator ();
855                 }
856
857                 [Test]
858                 public override void DefaultTypeTest ()
859                 {
860                         string code = GenerateDefaultType (Options);
861                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
862                                 "Public Delegate Sub (){0}", NewLine), code);
863                 }
864
865                 [Test]
866                 [ExpectedException (typeof (NullReferenceException))]
867                 public override void NullTypeTest ()
868                 {
869                         GenerateNullType (Options);
870                 }
871
872                 [Test]
873                 public override void SimpleTypeTest ()
874                 {
875                         string code = GenerateSimpleType (Options);
876                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
877                                 "Public Delegate Sub Test1(){0}", NewLine), code);
878                 }
879
880                 [Test]
881                 public override void DerivedTypeTest ()
882                 {
883                         string code = GenerateDerivedType (Options);
884                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
885                                 "Delegate Sub Test1(){0}", NewLine), code);
886                 }
887
888                 [Test]
889                 public override void AttributesAndTypeTest ()
890                 {
891                         CodeTypeDelegate delegateDecl = new CodeTypeDelegate ();
892                         delegateDecl.ReturnType = new CodeTypeReference (typeof (int));
893
894                         _typeDeclaration = delegateDecl;
895
896                         string code = GenerateAttributesAndType (Options);
897                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
898                                 "<A(),  _{0}" +
899                                 " B()>  _{0}" +
900                                 "Public Delegate Function Test1() As Integer{0}", NewLine), code);
901                 }
902
903                 [Test]
904                 public override void EventMembersTypeTest1 ()
905                 {
906                         string code = GenerateEventMembersType1 (Options);
907                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
908                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
909                 }
910
911                 [Test]
912                 public override void EventMembersTypeTest2 ()
913                 {
914                         string code = GenerateEventMembersType2 (Options);
915                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
916                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
917                 }
918
919                 [Test]
920                 public override void EventImplementationTypes ()
921                 {
922                         string code = GenerateEventImplementationTypes (Options);
923                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
924                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
925                 }
926
927                 /// <summary>
928                 /// Ensure no access modifiers are output if PrivateImplementationType
929                 /// is set.
930                 /// </summary>
931                 [Test]
932                 public override void EventPrivateImplementationType ()
933                 {
934                         string code = GenerateEventPrivateImplementationType (Options);
935                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
936                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
937                 }
938
939                 /// <summary>
940                 /// If both ImplementationTypes and PrivateImplementationType are set,
941                 /// then only ImplementationTypes are output.
942                 /// </summary>
943                 [Test]
944                 public override void EventImplementationTypeOrder ()
945                 {
946                         string code = GenerateEventImplementationTypeOrder (Options);
947                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
948                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
949                 }
950
951                 [Test]
952                 public override void FieldMembersAttributesTest ()
953                 {
954                         string code = GenerateFieldMembersAttributes (Options);
955                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
956                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
957                 }
958
959                 [Test]
960                 public override void FieldMembersTypeTest ()
961                 {
962                         string code = GenerateFieldMembersType (MemberAttributes.Public, Options);
963                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
964                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
965                 }
966
967                 [Test]
968                 public override void FieldNewSlotTest ()
969                 {
970                         string code = GenerateFieldMembersType (MemberAttributes.Assembly |
971                                 MemberAttributes.New, Options);
972                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
973                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
974                 }
975
976                 [Test]
977                 public override void PropertyMembersTypeTest1 ()
978                 {
979                         string code = GeneratePropertyMembersAttributes (Options);
980                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
981                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
982                 }
983
984                 [Test]
985                 public override void PropertyMembersTypeTest2 ()
986                 {
987                         string code = GeneratePropertyMembersType (MemberAttributes.Public,
988                                 false, false, Options);
989                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
990                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
991                 }
992
993                 [Test]
994                 public override void PropertyMembersTypeGetOnly ()
995                 {
996                         string code = GeneratePropertyMembersType (MemberAttributes.Family,
997                                 true, false, Options);
998                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
999                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1000                 }
1001
1002                 [Test]
1003                 public override void PropertyMembersTypeSetOnly ()
1004                 {
1005                         string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
1006                                 false, true, Options);
1007                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1008                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1009                 }
1010
1011                 [Test]
1012                 public override void PropertyMembersTypeGetSet ()
1013                 {
1014                         string code = GeneratePropertyMembersType (MemberAttributes.Family,
1015                                 true, true, Options);
1016                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1017                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1018                 }
1019
1020                 [Test]
1021                 public override void PropertyMembersTypeFamilyOrAssembly ()
1022                 {
1023                         string code = GeneratePropertyMembersType (MemberAttributes.FamilyOrAssembly,
1024                                 false, false, Options);
1025                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1026                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1027                 }
1028
1029                 [Test]
1030                 public override void PropertyMembersTypeAssembly ()
1031                 {
1032                         string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
1033                                 false, false, Options);
1034                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1035                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1036                 }
1037
1038                 [Test]
1039                 public override void PropertyParametersTest ()
1040                 {
1041                         string code = GeneratePropertyParameters (Options);
1042                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1043                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1044                 }
1045
1046                 [Test]
1047                 public override void PropertyIndexerTest1 ()
1048                 {
1049                         string code = GeneratePropertyIndexer (MemberAttributes.Public,
1050                                 false, false, true, Options);
1051                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1052                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1053                 }
1054
1055                 [Test]
1056                 public override void PropertyIndexerTest2 ()
1057                 {
1058                         string code = GeneratePropertyIndexer (MemberAttributes.Public,
1059                                 false, false, false, Options);
1060                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1061                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1062                 }
1063
1064                 [Test]
1065                 public override void PropertyIndexerGetOnly ()
1066                 {
1067                         string code = GeneratePropertyIndexer (MemberAttributes.Family,
1068                                 true, false, true, Options);
1069                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1070                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1071                 }
1072
1073                 [Test]
1074                 public override void PropertyIndexerSetOnly ()
1075                 {
1076                         string code = GeneratePropertyIndexer (MemberAttributes.Family,
1077                                 false, true, true, Options);
1078                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1079                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1080                 }
1081
1082                 [Test]
1083                 public override void PropertyImplementationTypes ()
1084                 {
1085                         string code = GeneratePropertyImplementationTypes (Options);
1086                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1087                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1088                 }
1089
1090                 [Test]
1091                 public override void PropertyOverloadsTest1 ()
1092                 {
1093                         string code = GeneratePropertyOverloads1 (Options);
1094                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1095                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1096                 }
1097
1098                 [Test]
1099                 public override void PropertyOverloadsTest2 ()
1100                 {
1101                         string code = GeneratePropertyOverloads2 (Options);
1102                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1103                                 "Public Delegate Sub Test1(){0}{0}{0}", NewLine), code);
1104                 }
1105
1106                 [Test]
1107                 public override void PropertyOverloadsTest3 ()
1108                 {
1109                         string code = GeneratePropertyOverloads3 (Options);
1110                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1111                                 "Public Delegate Sub Test1(){0}{0}{0}", NewLine), code);
1112                 }
1113
1114                 [Test]
1115                 public override void PropertyPrivateImplementationType ()
1116                 {
1117                         string code = GeneratePropertyPrivateImplementationType (Options);
1118                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1119                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1120                 }
1121
1122                 [Test]
1123                 public override void PropertyImplementationTypeOrder ()
1124                 {
1125                         string code = GeneratePropertyImplementationTypeOrder (Options);
1126                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1127                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1128                 }
1129
1130                 [Test]
1131                 public override void PropertyNewSlotTest ()
1132                 {
1133                         string code = GeneratePropertyMembersType (MemberAttributes.Private |
1134                                 MemberAttributes.New, true, true, Options);
1135                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1136                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1137                 }
1138
1139                 [Test]
1140                 public override void MethodMembersTypeTest1 ()
1141                 {
1142                         string code = GenerateMethodMembersType1 (Options);
1143                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1144                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1145                 }
1146
1147                 [Test]
1148                 public override void MethodMembersTypeTest2 ()
1149                 {
1150                         string code = GenerateMethodMembersType2 (Options);
1151                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1152                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1153                 }
1154
1155                 [Test]
1156                 public override void MethodMembersTypeTest3 ()
1157                 {
1158                         string code = GenerateMethodMembersType3 (Options);
1159                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1160                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1161                 }
1162
1163                 [Test]
1164                 public override void MethodImplementationTypes ()
1165                 {
1166                         string code = GenerateMethodImplementationTypes (Options);
1167                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1168                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1169                 }
1170
1171                 [Test]
1172                 public override void MethodOverloadsTest1 ()
1173                 {
1174                         string code = GenerateMethodOverloads1 (Options);
1175                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1176                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1177                 }
1178
1179                 [Test]
1180                 public override void MethodOverloadsTest2 ()
1181                 {
1182                         string code = GenerateMethodOverloads2 (Options);
1183                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1184                                 "Public Delegate Sub Test1(){0}{0}{0}", NewLine), code);
1185                 }
1186
1187                 [Test]
1188                 public override void MethodOverloadsTest3 ()
1189                 {
1190                         string code = GenerateMethodOverloads3 (Options);
1191                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1192                                 "Public Delegate Sub Test1(){0}{0}{0}", NewLine), code);
1193                 }
1194
1195                 [Test]
1196                 public override void MethodPrivateImplementationType ()
1197                 {
1198                         string code = GenerateMethodPrivateImplementationType (Options);
1199                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1200                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1201                 }
1202
1203                 [Test]
1204                 public override void MethodImplementationTypeOrder ()
1205                 {
1206                         string code = GenerateMethodImplementationTypeOrder (Options);
1207                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1208                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1209                 }
1210
1211                 [Test]
1212                 public override void MethodParamArrayAttribute ()
1213                 {
1214                         string code = GenerateMethodParamArrayAttribute (Options);
1215                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1216                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1217                 }
1218
1219                 [Test]
1220                 public override void MethodReturnTypeAttributes ()
1221                 {
1222                         string code = GenerateMethodReturnTypeAttributes (Options);
1223                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1224                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1225                 }
1226
1227                 [Test]
1228                 public override void MethodNewSlotTest ()
1229                 {
1230                         string code = GenerateMethodNewSlot (Options);
1231                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1232                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1233                 }
1234
1235                 [Test]
1236                 public override void ConstructorAttributesTest ()
1237                 {
1238                         string code = GenerateConstructorAttributes (Options);
1239                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1240                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1241                 }
1242
1243                 [Test]
1244                 public override void ConstructorParametersTest ()
1245                 {
1246                         string code = GenerateConstructorParameters (Options);
1247                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1248                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1249                 }
1250
1251                 [Test]
1252                 public override void ConstructorParameterAttributesTest ()
1253                 {
1254                         string code = GenerateConstructorParameterAttributes (Options);
1255                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1256                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1257                 }
1258
1259                 [Test]
1260                 public override void BaseConstructorSingleArg ()
1261                 {
1262                         string code = GenerateBaseConstructor (false, Options);
1263                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1264                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1265                 }
1266
1267                 [Test]
1268                 public override void BaseConstructorMultipleArgs ()
1269                 {
1270                         string code = GenerateBaseConstructor (true, Options);
1271                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1272                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1273                 }
1274
1275                 [Test]
1276                 public override void ChainedConstructorSingleArg ()
1277                 {
1278                         string code = GenerateChainedConstructor (false, Options);
1279                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1280                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1281                 }
1282
1283                 [Test]
1284                 public override void ChainedConstructorMultipleArgs ()
1285                 {
1286                         string code = GenerateChainedConstructor (true, Options);
1287                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1288                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1289                 }
1290
1291                 [Test]
1292                 public override void TypeConstructorTest ()
1293                 {
1294                         string code = GenerateTypeConstructor (Options);
1295                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1296                                 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1297                 }
1298
1299                 [Test]
1300                 public override void EntryPointMethodTest ()
1301                 {
1302                         string code = GenerateEntryPointMethod (Options);
1303                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1304                                 "Public Delegate Sub Test1(){0}{0}" +
1305                                 "<A()>  _{0}" +
1306                                 "Public Shared Sub Main(){0}" +
1307                                 "    Dim x As Test.InnerType{0}" +
1308                                 "End Sub{0}", NewLine), code);
1309                 }
1310                 
1311                 [Test]
1312                 public void DelegateWithParametersTest ()
1313                 {
1314                         CodeTypeDelegate type = new CodeTypeDelegate("A");
1315                         type.Parameters.Add (new CodeParameterDeclarationExpression ("type", "param"));
1316                         
1317                         string code = GenerateCodeFromType (type, Options);
1318                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture, 
1319                                 "Public Delegate Sub A(ByVal param As type){0}", NewLine), code);
1320                 }
1321                 
1322                 [Test]
1323                 public override void PartialTypeTest ()
1324                 {
1325                         string code = GeneratePartialType (Options);
1326                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1327                                 "Public Delegate Sub Test1(){0}", NewLine), code);
1328                 }
1329         }
1330
1331         [TestFixture]
1332         public class CodeGeneratorFromTypeTest_Interface : CodeGeneratorFromTypeTestBase
1333         {
1334                 private CodeTypeDeclaration _typeDeclaration;
1335                 private ICodeGenerator _codeGenerator;
1336
1337                 protected override ICodeGenerator CodeGenerator
1338                 {
1339                         get { return _codeGenerator; }
1340                 }
1341
1342                 protected override CodeTypeDeclaration TypeDeclaration
1343                 {
1344                         get { return _typeDeclaration; }
1345                 }
1346
1347                 [SetUp]
1348                 public override void SetUp ()
1349                 {
1350                         base.SetUp ();
1351                         _typeDeclaration = new CodeTypeDeclaration ();
1352                         _typeDeclaration.IsInterface = true;
1353
1354                         CodeDomProvider provider = new VBCodeProvider ();
1355                         _codeGenerator = provider.CreateGenerator ();
1356                 }
1357
1358                 [Test]
1359                 public override void DefaultTypeTest ()
1360                 {
1361                         string code = GenerateDefaultType (Options);
1362                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1363                                 "Public Interface {0}" +
1364                                 "End Interface{0}", NewLine), code);
1365                 }
1366
1367                 [Test]
1368                 [ExpectedException (typeof (NullReferenceException))]
1369                 public override void NullTypeTest ()
1370                 {
1371                         GenerateNullType (Options);
1372                 }
1373
1374                 [Test]
1375                 public override void SimpleTypeTest ()
1376                 {
1377                         string code = GenerateSimpleType (Options);
1378                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1379                                 "Public Interface Test1{0}" +
1380                                 "End Interface{0}", NewLine), code);
1381                 }
1382
1383                 [Test]
1384                 public override void DerivedTypeTest ()
1385                 {
1386                         string code = GenerateDerivedType (Options);
1387                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1388                                 "Friend Interface Test1{0}" +
1389                                 "    Inherits Integer, System.Security.Principal.IIdentity, String, System.Security.IPermission{0}" +
1390                                 "End Interface{0}", NewLine), code);
1391                 }
1392
1393                 [Test]
1394                 public override void AttributesAndTypeTest ()
1395                 {
1396                         string code = GenerateAttributesAndType (Options);
1397                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1398                                 "<A(),  _{0}" +
1399                                 " B()>  _{0}" +
1400                                 "Public Interface Test1{0}" +
1401                                 "End Interface{0}", NewLine), code);
1402                 }
1403
1404                 [Test]
1405                 public override void EventMembersTypeTest1 ()
1406                 {
1407                         string code = GenerateEventMembersType1 (Options);
1408                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1409                                 "Public Interface Test1{0}" +
1410                                 "    {0}" +
1411                                 "    <A(),  _{0}" +
1412                                 "     B()>  _{0}" +
1413                                 "    Private Event __exception As System.Void{0}" +
1414                                 "End Interface{0}", NewLine), code);
1415                 }
1416
1417                 [Test]
1418                 public override void EventMembersTypeTest2 ()
1419                 {
1420                         string code = GenerateEventMembersType2 (Options);
1421                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1422                                 "Public Interface Test1{0}" +
1423                                 "    {0}" +
1424                                 "    Public Event Click As Integer{0}" +
1425                                 "End Interface{0}", NewLine), code);
1426                 }
1427
1428                 [Test]
1429                 public override void EventImplementationTypes ()
1430                 {
1431                         string code = GenerateEventImplementationTypes (Options);
1432                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1433                                 "Public Interface Test1{0}" +
1434                                 "    {0}" +
1435                                 "    Friend Event Click As Integer Implements IPolicy.Click , IWhatever.Click{0}" +
1436                                 "End Interface{0}", NewLine), code);
1437                 }
1438
1439                 [Test]
1440                 public override void EventPrivateImplementationType ()
1441                 {
1442                         string code = GenerateEventPrivateImplementationType (Options);
1443                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1444                                 "Public Interface Test1{0}" +
1445                                 "    {0}" +
1446                                 "    Protected Event System_Int32_Click As Integer Implements Integer.Click{0}" +
1447                                 "End Interface{0}", NewLine), code);
1448                 }
1449
1450                 [Test]
1451                 public override void EventImplementationTypeOrder ()
1452                 {
1453                         string code = GenerateEventImplementationTypeOrder (Options);
1454                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1455                                 "Public Interface Test1{0}" +
1456                                 "    {0}" +
1457                                 "    Public Event System_Int32_Click As Integer Implements IPolicy.Click{0}" +
1458                                 "End Interface{0}", NewLine), code);
1459                 }
1460
1461                 [Test]
1462                 public override void FieldMembersAttributesTest ()
1463                 {
1464                         string code = GenerateFieldMembersAttributes (Options);
1465                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1466                                 "Public Interface Test1{0}" +
1467                                 "    {0}" +
1468                                 "End Interface{0}", NewLine), code);
1469                 }
1470
1471                 [Test]
1472                 public override void FieldMembersTypeTest ()
1473                 {
1474                         string code = GenerateFieldMembersType (MemberAttributes.Public, Options);
1475                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1476                                 "Public Interface Test1{0}" +
1477                                 "    {0}" +
1478                                 "End Interface{0}", NewLine), code);
1479                 }
1480
1481                 [Test]
1482                 public override void FieldNewSlotTest ()
1483                 {
1484                         string code = GenerateFieldMembersType (MemberAttributes.Assembly |
1485                                 MemberAttributes.New, Options);
1486                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1487                                 "Public Interface Test1{0}" +
1488                                 "    {0}" +
1489                                 "End Interface{0}", NewLine), code);
1490                 }
1491
1492                 [Test]
1493                 public override void PropertyMembersTypeTest1 ()
1494                 {
1495                         string code = GeneratePropertyMembersAttributes (Options);
1496                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1497                                 "Public Interface Test1{0}" +
1498                                 "    {0}" +
1499                                 "    <A(),  _{0}" +
1500                                 "     B()>  _{0}" +
1501                                 "    Property () As System.Void{0}" +
1502                                 "End Interface{0}", NewLine), code);
1503                 }
1504
1505                 [Test]
1506                 public override void PropertyMembersTypeTest2 ()
1507                 {
1508                         string code = GeneratePropertyMembersType (MemberAttributes.Public,
1509                                 false, false, Options);
1510                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1511                                 "Public Interface Test1{0}" +
1512                                 "    {0}" +
1513                                 "    Property Name() As Integer{0}" +
1514                                 "End Interface{0}", NewLine), code);
1515                 }
1516
1517                 [Test]
1518                 public override void PropertyMembersTypeGetOnly ()
1519                 {
1520                         string code = GeneratePropertyMembersType (MemberAttributes.Family,
1521                                 true, false, Options);
1522                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1523                                 "Public Interface Test1{0}" +
1524                                 "    {0}" +
1525                                 "    ReadOnly Property Name() As Integer{0}" +
1526                                 "End Interface{0}", NewLine), code);
1527                 }
1528
1529                 [Test]
1530                 public override void PropertyMembersTypeSetOnly ()
1531                 {
1532                         string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
1533                                 false, true, Options);
1534                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1535                                 "Public Interface Test1{0}" +
1536                                 "    {0}" +
1537                                 "    WriteOnly Property Name() As Integer{0}" +
1538                                 "End Interface{0}", NewLine), code);
1539                 }
1540
1541                 [Test]
1542                 public override void PropertyMembersTypeGetSet ()
1543                 {
1544                         string code = GeneratePropertyMembersType (MemberAttributes.Family,
1545                                 true, true, Options);
1546                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1547                                 "Public Interface Test1{0}" +
1548                                 "    {0}" +
1549                                 "    Property Name() As Integer{0}" +
1550                                 "End Interface{0}", NewLine), code);
1551                 }
1552
1553                 [Test]
1554                 public override void PropertyMembersTypeFamilyOrAssembly ()
1555                 {
1556                         string code = GeneratePropertyMembersType (MemberAttributes.FamilyOrAssembly,
1557                                 false, false, Options);
1558                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1559                                 "Public Interface Test1{0}" +
1560                                 "    {0}" +
1561                                 "    Property Name() As Integer{0}" +
1562                                 "End Interface{0}", NewLine), code);
1563                 }
1564
1565                 [Test]
1566                 public override void PropertyMembersTypeAssembly ()
1567                 {
1568                         string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
1569                                 false, false, Options);
1570                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1571                                 "Public Interface Test1{0}" +
1572                                 "    {0}" +
1573                                 "    Property Name() As Integer{0}" +
1574                                 "End Interface{0}", NewLine), code);
1575                 }
1576
1577                 [Test]
1578                 public override void PropertyParametersTest ()
1579                 {
1580                         string code = GeneratePropertyParameters (Options);
1581                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1582                                 "Public Interface Test1{0}" +
1583                                 "    {0}" +
1584                                 "    Property Name(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
1585                                 "End Interface{0}", NewLine), code);
1586                 }
1587
1588                 [Test]
1589                 public override void PropertyIndexerTest1 ()
1590                 {
1591                         string code = GeneratePropertyIndexer (MemberAttributes.Public,
1592                                 false, false, true, Options);
1593                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1594                                 "Public Interface Test1{0}" +
1595                                 "    {0}" +
1596                                 "    Default Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
1597                                 "End Interface{0}", NewLine), code);
1598                 }
1599
1600                 [Test]
1601                 public override void PropertyIndexerTest2 ()
1602                 {
1603                         string code = GeneratePropertyIndexer (MemberAttributes.Public,
1604                                 false, false, false, Options);
1605                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1606                                 "Public Interface Test1{0}" +
1607                                 "    {0}" +
1608                                 "    Property iTem() As Integer{0}" +
1609                                 "End Interface{0}", NewLine), code);
1610                 }
1611
1612                 [Test]
1613                 public override void PropertyIndexerGetOnly ()
1614                 {
1615                         string code = GeneratePropertyIndexer (MemberAttributes.Family,
1616                                 true, false, true, Options);
1617                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1618                                 "Public Interface Test1{0}" +
1619                                 "    {0}" +
1620                                 "    Default ReadOnly Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
1621                                 "End Interface{0}", NewLine), code);
1622                 }
1623
1624                 [Test]
1625                 public override void PropertyIndexerSetOnly ()
1626                 {
1627                         string code = GeneratePropertyIndexer (MemberAttributes.Family,
1628                                 false, true, true, Options);
1629                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1630                                 "Public Interface Test1{0}" +
1631                                 "    {0}" +
1632                                 "    Default WriteOnly Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
1633                                 "End Interface{0}", NewLine), code);
1634                 }
1635
1636                 [Test]
1637                 public override void PropertyImplementationTypes ()
1638                 {
1639                         string code = GeneratePropertyImplementationTypes (Options);
1640                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1641                                 "Public Interface Test1{0}" +
1642                                 "    {0}" +
1643                                 "    Property Name() As Integer Implements IPolicy.Name , IWhatever.Name{0}" +
1644                                 "End Interface{0}", NewLine), code);
1645                 }
1646
1647                 [Test]
1648                 public override void PropertyOverloadsTest1 ()
1649                 {
1650                         string code = GeneratePropertyOverloads1 (Options);
1651                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1652                                 "Public Interface Test1{0}" +
1653                                 "    {0}" +
1654                                 "    Property Name() As Integer{0}" +
1655                                 "End Interface{0}", NewLine), code);
1656                 }
1657
1658                 [Test]
1659                 public override void PropertyOverloadsTest2 ()
1660                 {
1661                         string code = GeneratePropertyOverloads2 (Options);
1662                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1663                                 "Public Interface Test1{0}" +
1664                                 "    {0}" +
1665                                 "    Property Name() As Integer{0}" +
1666                                 "    {0}" +
1667                                 "    Property Name(ByVal value1 As Object) As Integer{0}" +
1668                                 "End Interface{0}", NewLine), code);
1669                 }
1670
1671                 [Test]
1672                 public override void PropertyOverloadsTest3 ()
1673                 {
1674                         string code = GeneratePropertyOverloads3 (Options);
1675                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1676                                 "Public Interface Test1{0}" +
1677                                 "    {0}" +
1678                                 "    Property Name() As Integer{0}" +
1679                                 "    {0}" +
1680                                 "    Property System_Int32_Name(ByVal value1 As Object) As Integer Implements Integer.Name{0}" +
1681                                 "End Interface{0}", NewLine), code);
1682                 }
1683
1684                 [Test]
1685                 public override void PropertyPrivateImplementationType ()
1686                 {
1687                         string code = GeneratePropertyPrivateImplementationType (Options);
1688                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1689                                 "Public Interface Test1{0}" +
1690                                 "    {0}" +
1691                                 "    Property System_Int32_Item(ByVal value1 As Object) As Integer Implements Integer.Item{0}" +
1692                                 "End Interface{0}", NewLine), code);
1693                 }
1694
1695                 [Test]
1696                 public override void PropertyImplementationTypeOrder ()
1697                 {
1698                         string code = GeneratePropertyImplementationTypeOrder (Options);
1699                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1700                                 "Public Interface Test1{0}" +
1701                                 "    {0}" +
1702                                 "    Property System_Int32_Item(ByVal value1 As Object) As Integer Implements IPolicy.Item{0}" +
1703                                 "End Interface{0}", NewLine), code);
1704                 }
1705
1706                 [Test]
1707                 public override void PropertyNewSlotTest ()
1708                 {
1709                         string code = GeneratePropertyMembersType (MemberAttributes.Private |
1710                                 MemberAttributes.New, true, true, Options);
1711                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1712                                 "Public Interface Test1{0}" +
1713                                 "    {0}" +
1714                                 "    Shadows Property Name() As Integer{0}" +
1715                                 "End Interface{0}", NewLine), code);
1716                 }
1717
1718                 [Test]
1719                 public override void MethodMembersTypeTest1 ()
1720                 {
1721                         string code = GenerateMethodMembersType1 (Options);
1722                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1723                                 "Public Interface Test1{0}" +
1724                                 "    {0}" +
1725                                 "    <A(),  _{0}" +
1726                                 "     B()>  _{0}" +
1727                                 "    Sub (){0}" +
1728                                 "End Interface{0}", NewLine), code);
1729                 }
1730
1731                 [Test]
1732                 public override void MethodMembersTypeTest2 ()
1733                 {
1734                         string code = GenerateMethodMembersType2 (Options);
1735                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1736                                 "Public Interface Test1{0}" +
1737                                 "    {0}" +
1738                                 "    Function Something(ByVal value1 As Object, ByVal value2 As Object, ByRef index As Integer, ByRef count As Integer) As Integer{0}" +
1739                                 "End Interface{0}", NewLine), code);
1740                 }
1741
1742                 [Test]
1743                 public override void MethodMembersTypeTest3 ()
1744                 {
1745                         string code = GenerateMethodMembersType3 (Options);
1746                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1747                                 "Public Interface Test1{0}" +
1748                                 "    {0}" +
1749                                 "    Function Something(<A(), B()> ByVal value As Object, <C(A1:=false, A2:=true), D()> ByRef __exception As Integer) As Integer{0}" +
1750                                 "End Interface{0}", NewLine), code);
1751                 }
1752
1753                 [Test]
1754                 public override void MethodImplementationTypes ()
1755                 {
1756                         string code = GenerateMethodImplementationTypes (Options);
1757                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1758                                 "Public Interface Test1{0}" +
1759                                 "    {0}" +
1760                                 "    Function Execute() As Integer Implements IPolicy.Execute , IWhatever.Execute{0}" +
1761                                 "End Interface{0}", NewLine), code);
1762                 }
1763
1764                 [Test]
1765                 public override void MethodOverloadsTest1 ()
1766                 {
1767                         string code = GenerateMethodOverloads1 (Options);
1768                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1769                                 "Public Interface Test1{0}" +
1770                                 "    {0}" +
1771                                 "    Function Execute() As Integer{0}" +
1772                                 "End Interface{0}", NewLine), code);
1773                 }
1774
1775                 [Test]
1776                 public override void MethodOverloadsTest2 ()
1777                 {
1778                         string code = GenerateMethodOverloads2 (Options);
1779                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1780                                 "Public Interface Test1{0}" +
1781                                 "    {0}" +
1782                                 "    Sub Execute(){0}" +
1783                                 "    {0}" +
1784                                 "    Function Execute(ByVal value1 As Object) As Integer{0}" +
1785                                 "End Interface{0}", NewLine), code);
1786                 }
1787
1788                 [Test]
1789                 public override void MethodOverloadsTest3 ()
1790                 {
1791                         string code = GenerateMethodOverloads3 (Options);
1792                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1793                                 "Public Interface Test1{0}" +
1794                                 "    {0}" +
1795                                 "    Sub Execute(){0}" +
1796                                 "    {0}" +
1797                                 "    Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements Integer.Execute{0}" +
1798                                 "End Interface{0}", NewLine), code);
1799                 }
1800
1801                 [Test]
1802                 public override void MethodPrivateImplementationType ()
1803                 {
1804                         string code = GenerateMethodPrivateImplementationType (Options);
1805                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1806                                 "Public Interface Test1{0}" +
1807                                 "    {0}" +
1808                                 "    Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements Integer.Execute{0}" +
1809                                 "End Interface{0}", NewLine), code);
1810                 }
1811
1812                 [Test]
1813                 public override void MethodImplementationTypeOrder ()
1814                 {
1815                         string code = GenerateMethodImplementationTypeOrder (Options);
1816                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1817                                 "Public Interface Test1{0}" +
1818                                 "    {0}" +
1819                                 "    Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements IPolicy.Execute{0}" +
1820                                 "End Interface{0}", NewLine), code);
1821                 }
1822
1823                 [Test]
1824                 public override void MethodParamArrayAttribute ()
1825                 {
1826                         string code = GenerateMethodParamArrayAttribute (Options);
1827                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1828                                 "Public Interface Test1{0}" +
1829                                 "    {0}" +
1830                                 "    Function Something(<A(), System.ParamArrayAttribute(), B()> ByRef value As Object, <C()> ByRef __exception As Integer) As Integer{0}" +
1831                                 "End Interface{0}", NewLine), code);
1832                 }
1833
1834                 [Test]
1835                 public override void MethodReturnTypeAttributes ()
1836                 {
1837                         string code = GenerateMethodReturnTypeAttributes (Options);
1838                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1839                                 "Public Interface Test1{0}" +
1840                                 "    {0}" +
1841                                 "    <A(),  _{0}" +
1842                                 "     B(),  _{0}" +
1843                                 "     System.ParamArrayAttribute()>  _{0}" +
1844                                 "    Function Execute() As <C(A1:=false, A2:=true), System.ParamArrayAttribute(), D()> Integer{0}" +
1845                                 "End Interface{0}", NewLine), code);
1846                 }
1847
1848                 [Test]
1849                 public override void MethodNewSlotTest ()
1850                 {
1851                         string code = GenerateMethodNewSlot (Options);
1852                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1853                                 "Public Interface Test1{0}" +
1854                                 "    {0}" +
1855                                 "    Shadows Function Execute() As Integer{0}" +
1856                                 "End Interface{0}", NewLine), code);
1857                 }
1858
1859                 [Test]
1860                 public override void ConstructorAttributesTest ()
1861                 {
1862                         string code = GenerateConstructorAttributes (Options);
1863                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1864                                 "Public Interface Test1{0}" +
1865                                 "    {0}" +
1866                                 "End Interface{0}", NewLine), code);
1867                 }
1868
1869                 [Test]
1870                 public override void ConstructorParametersTest ()
1871                 {
1872                         string code = GenerateConstructorParameters (Options);
1873                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1874                                 "Public Interface Test1{0}" +
1875                                 "    {0}" +
1876                                 "End Interface{0}", NewLine), code);
1877                 }
1878
1879                 [Test]
1880                 public override void ConstructorParameterAttributesTest ()
1881                 {
1882                         string code = GenerateConstructorParameterAttributes (Options);
1883                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1884                                 "Public Interface Test1{0}" +
1885                                 "    {0}" +
1886                                 "End Interface{0}", NewLine), code);
1887                 }
1888
1889                 [Test]
1890                 public override void BaseConstructorSingleArg ()
1891                 {
1892                         string code = GenerateBaseConstructor (false, Options);
1893                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1894                                 "Public Interface Test1{0}" +
1895                                 "    {0}" +
1896                                 "End Interface{0}", NewLine), code);
1897                 }
1898
1899                 [Test]
1900                 public override void BaseConstructorMultipleArgs ()
1901                 {
1902                         string code = GenerateBaseConstructor (true, Options);
1903                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1904                                 "Public Interface Test1{0}" +
1905                                 "    {0}" +
1906                                 "End Interface{0}", NewLine), code);
1907                 }
1908
1909                 [Test]
1910                 public override void ChainedConstructorSingleArg ()
1911                 {
1912                         string code = GenerateChainedConstructor (false, Options);
1913                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1914                                 "Public Interface Test1{0}" +
1915                                 "    {0}" +
1916                                 "End Interface{0}", NewLine), code);
1917                 }
1918
1919                 [Test]
1920                 public override void ChainedConstructorMultipleArgs ()
1921                 {
1922                         string code = GenerateChainedConstructor (true, Options);
1923                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1924                                 "Public Interface Test1{0}" +
1925                                 "    {0}" +
1926                                 "End Interface{0}", NewLine), code);
1927                 }
1928
1929                 [Test]
1930                 public override void TypeConstructorTest ()
1931                 {
1932                         string code = GenerateTypeConstructor (Options);
1933                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1934                                 "Public Interface Test1{0}" +
1935                                 "    {0}" +
1936                                 "End Interface{0}", NewLine), code);
1937                 }
1938
1939                 [Test]
1940                 public override void EntryPointMethodTest ()
1941                 {
1942                         string code = GenerateEntryPointMethod (Options);
1943                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1944                                 "Public Interface Test1{0}" +
1945                                 "    {0}" +
1946                                 "    <A()>  _{0}" +
1947                                 "    Public Shared Sub Main(){0}" +
1948                                 "        Dim x As Test.InnerType{0}" +
1949                                 "    End Sub{0}" +
1950                                 "End Interface{0}", NewLine), code);
1951                 }
1952                 
1953                 [Test]
1954                 public override void PartialTypeTest ()
1955                 {
1956                         string code = GeneratePartialType (Options);
1957                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1958                                 "Partial Public Interface Test1{0}" +
1959                                 "End Interface{0}", NewLine), code);
1960                 }
1961         }
1962
1963         [TestFixture]
1964         public class CodeGeneratorFromTypeTest_Struct : CodeGeneratorFromTypeTestBase
1965         {
1966                 private CodeTypeDeclaration _typeDeclaration;
1967                 private ICodeGenerator _codeGenerator;
1968
1969                 protected override ICodeGenerator CodeGenerator
1970                 {
1971                         get { return _codeGenerator; }
1972                 }
1973
1974                 protected override CodeTypeDeclaration TypeDeclaration
1975                 {
1976                         get { return _typeDeclaration; }
1977                 }
1978
1979                 [SetUp]
1980                 public override void SetUp ()
1981                 {
1982                         base.SetUp ();
1983                         _typeDeclaration = new CodeTypeDeclaration ();
1984                         _typeDeclaration.IsStruct = true;
1985
1986                         CodeDomProvider provider = new VBCodeProvider ();
1987                         _codeGenerator = provider.CreateGenerator ();
1988                 }
1989
1990                 [Test]
1991                 public override void DefaultTypeTest ()
1992                 {
1993                         string code = GenerateDefaultType (Options);
1994                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1995                                 "Public Structure {0}" +
1996                                 "End Structure{0}", NewLine), code);
1997                 }
1998
1999                 [Test]
2000                 [ExpectedException (typeof (NullReferenceException))]
2001                 public override void NullTypeTest ()
2002                 {
2003                         GenerateNullType (Options);
2004                 }
2005
2006                 [Test]
2007                 public override void SimpleTypeTest ()
2008                 {
2009                         string code = GenerateSimpleType (Options);
2010                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2011                                 "Public Structure Test1{0}" +
2012                                 "End Structure{0}", NewLine), code);
2013                 }
2014
2015                 [Test]
2016                 public override void DerivedTypeTest ()
2017                 {
2018                         string code = GenerateDerivedType (Options);
2019                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2020                                 "Friend Structure Test1{0}" +
2021                                 "    Implements Integer, System.Security.Principal.IIdentity, String, System.Security.IPermission{0}" +
2022                                 "End Structure{0}", NewLine), code);
2023                 }
2024
2025                 [Test]
2026                 public override void AttributesAndTypeTest ()
2027                 {
2028                         string code = GenerateAttributesAndType (Options);
2029                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2030                                 "<A(),  _{0}" +
2031                                 " B()>  _{0}" +
2032                                 "Public Structure Test1{0}" +
2033                                 "End Structure{0}", NewLine), code);
2034                 }
2035
2036                 [Test]
2037                 public override void EventMembersTypeTest1 ()
2038                 {
2039                         string code = GenerateEventMembersType1 (Options);
2040                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2041                                 "Public Structure Test1{0}" +
2042                                 "    {0}" +
2043                                 "    <A(),  _{0}" +
2044                                 "     B()>  _{0}" +
2045                                 "    Private Event __exception As System.Void{0}" +
2046                                 "End Structure{0}", NewLine), code);
2047                 }
2048
2049                 [Test]
2050                 public override void EventMembersTypeTest2 ()
2051                 {
2052                         string code = GenerateEventMembersType2 (Options);
2053                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2054                                 "Public Structure Test1{0}" +
2055                                 "    {0}" +
2056                                 "    Public Event Click As Integer{0}" +
2057                                 "End Structure{0}", NewLine), code);
2058                 }
2059
2060                 [Test]
2061                 public override void EventImplementationTypes ()
2062                 {
2063                         string code = GenerateEventImplementationTypes (Options);
2064                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2065                                 "Public Structure Test1{0}" +
2066                                 "    {0}" +
2067                                 "    Friend Event Click As Integer Implements IPolicy.Click , IWhatever.Click{0}" +
2068                                 "End Structure{0}", NewLine), code);
2069                 }
2070
2071                 [Test]
2072                 public override void EventPrivateImplementationType ()
2073                 {
2074                         string code = GenerateEventPrivateImplementationType (Options);
2075                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2076                                 "Public Structure Test1{0}" +
2077                                 "    {0}" +
2078                                 "    Protected Event System_Int32_Click As Integer Implements Integer.Click{0}" +
2079                                 "End Structure{0}", NewLine), code);
2080                 }
2081
2082                 [Test]
2083                 public override void EventImplementationTypeOrder ()
2084                 {
2085                         string code = GenerateEventImplementationTypeOrder (Options);
2086                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2087                                 "Public Structure Test1{0}" +
2088                                 "    {0}" +
2089                                 "    Public Event System_Int32_Click As Integer Implements IPolicy.Click{0}" +
2090                                 "End Structure{0}", NewLine), code);
2091                 }
2092
2093                 [Test]
2094                 public override void FieldMembersAttributesTest ()
2095                 {
2096                         string code = GenerateFieldMembersAttributes (Options);
2097                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2098                                 "Public Structure Test1{0}" +
2099                                 "    {0}" +
2100                                 "    <A(),  _{0}" +
2101                                 "     B()>  _{0}" +
2102                                 "    Private __exception As System.Void{0}" +
2103                                 "End Structure{0}", NewLine), code);
2104                 }
2105
2106                 [Test]
2107                 public override void FieldMembersTypeTest ()
2108                 {
2109                         string code = GenerateFieldMembersType (MemberAttributes.Public, Options);
2110                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2111                                 "Public Structure Test1{0}" +
2112                                 "    {0}" +
2113                                 "    Public Name As Integer = 2{0}" +
2114                                 "End Structure{0}", NewLine), code);
2115                 }
2116
2117                 [Test]
2118                 public override void FieldNewSlotTest ()
2119                 {
2120                         string code = GenerateFieldMembersType (MemberAttributes.Assembly |
2121                                 MemberAttributes.New, Options);
2122                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2123                                 "Public Structure Test1{0}" +
2124                                 "    {0}" +
2125                                 "    Friend Shadows Name As Integer = 2{0}" +
2126                                 "End Structure{0}", NewLine), code);
2127                 }
2128
2129                 [Test]
2130                 public override void PropertyMembersTypeTest1 ()
2131                 {
2132                         string code = GeneratePropertyMembersAttributes (Options);
2133                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2134                                 "Public Structure Test1{0}" +
2135                                 "    {0}" +
2136                                 "    <A(),  _{0}" +
2137                                 "     B()>  _{0}" +
2138                                 "    Private Property () As System.Void{0}" +
2139                                 "    End Property{0}" +
2140                                 "End Structure{0}", NewLine), code);
2141                 }
2142
2143                 [Test]
2144                 public override void PropertyMembersTypeTest2 ()
2145                 {
2146                         string code = GeneratePropertyMembersType (MemberAttributes.Public,
2147                                 false, false, Options);
2148                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2149                                 "Public Structure Test1{0}" +
2150                                 "    {0}" +
2151                                 "    Public Overridable Property Name() As Integer{0}" +
2152                                 "    End Property{0}" +
2153                                 "End Structure{0}", NewLine), code);
2154                 }
2155
2156                 [Test]
2157                 public override void PropertyMembersTypeGetOnly ()
2158                 {
2159                         string code = GeneratePropertyMembersType (MemberAttributes.Family,
2160                                 true, false, Options);
2161                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2162                                 "Public Structure Test1{0}" +
2163                                 "    {0}" +
2164                                 "    Protected Overridable ReadOnly Property Name() As Integer{0}" +
2165                                 "        Get{0}" +
2166                                 "        End Get{0}" +
2167                                 "    End Property{0}" +
2168                                 "End Structure{0}", NewLine), code);
2169                 }
2170
2171                 [Test]
2172                 public override void PropertyMembersTypeSetOnly ()
2173                 {
2174                         string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
2175                                 false, true, Options);
2176                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2177                                 "Public Structure Test1{0}" +
2178                                 "    {0}" +
2179                                 "    Friend Overridable WriteOnly Property Name() As Integer{0}" +
2180                                 "        Set{0}" +
2181                                 "        End Set{0}" +
2182                                 "    End Property{0}" +
2183                                 "End Structure{0}", NewLine), code);
2184                 }
2185
2186                 [Test]
2187                 public override void PropertyMembersTypeGetSet ()
2188                 {
2189                         string code = GeneratePropertyMembersType (MemberAttributes.Family,
2190                                 true, true, Options);
2191                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2192                                 "Public Structure Test1{0}" +
2193                                 "    {0}" +
2194                                 "    Protected Overridable Property Name() As Integer{0}" +
2195                                 "        Get{0}" +
2196                                 "        End Get{0}" +
2197                                 "        Set{0}" +
2198                                 "        End Set{0}" +
2199                                 "    End Property{0}" +
2200                                 "End Structure{0}", NewLine), code);
2201                 }
2202
2203                 [Test]
2204                 public override void PropertyMembersTypeFamilyOrAssembly ()
2205                 {
2206                         string code = GeneratePropertyMembersType (MemberAttributes.FamilyOrAssembly,
2207                                 false, false, Options);
2208                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2209                                 "Public Structure Test1{0}" +
2210                                 "    {0}" +
2211                                 "    Protected Friend Property Name() As Integer{0}" +
2212                                 "    End Property{0}" +
2213                                 "End Structure{0}", NewLine), code);
2214                 }
2215
2216                 [Test]
2217                 public override void PropertyMembersTypeAssembly ()
2218                 {
2219                         string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
2220                                 false, false, Options);
2221                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2222                                 "Public Structure Test1{0}" +
2223                                 "    {0}" +
2224                                 "    Friend Overridable Property Name() As Integer{0}" +
2225                                 "    End Property{0}" +
2226                                 "End Structure{0}", NewLine), code);
2227                 }
2228
2229                 [Test]
2230                 public override void PropertyParametersTest ()
2231                 {
2232                         string code = GeneratePropertyParameters (Options);
2233                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2234                                 "Public Structure Test1{0}" +
2235                                 "    {0}" +
2236                                 "    Public Overridable Property Name(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
2237                                 "    End Property{0}" +
2238                                 "End Structure{0}", NewLine), code);
2239                 }
2240
2241                 [Test]
2242                 public override void PropertyIndexerTest1 ()
2243                 {
2244                         string code = GeneratePropertyIndexer (MemberAttributes.Public,
2245                                 false, false, true, Options);
2246                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2247                                 "Public Structure Test1{0}" +
2248                                 "    {0}" +
2249                                 "    Public Overridable Default Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
2250                                 "    End Property{0}" +
2251                                 "End Structure{0}", NewLine), code);
2252                 }
2253
2254                 [Test]
2255                 public override void PropertyIndexerTest2 ()
2256                 {
2257                         string code = GeneratePropertyIndexer (MemberAttributes.Public,
2258                                 false, false, false, Options);
2259                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2260                                 "Public Structure Test1{0}" +
2261                                 "    {0}" +
2262                                 "    Public Overridable Property iTem() As Integer{0}" +
2263                                 "    End Property{0}" +
2264                                 "End Structure{0}", NewLine), code);
2265                 }
2266
2267                 [Test]
2268                 public override void PropertyIndexerGetOnly ()
2269                 {
2270                         string code = GeneratePropertyIndexer (MemberAttributes.Family,
2271                                 true, false, true, Options);
2272                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2273                                 "Public Structure Test1{0}" +
2274                                 "    {0}" +
2275                                 "    Protected Overridable Default ReadOnly Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
2276                                 "        Get{0}" +
2277                                 "        End Get{0}" +
2278                                 "    End Property{0}" +
2279                                 "End Structure{0}", NewLine), code);
2280                 }
2281
2282                 [Test]
2283                 public override void PropertyIndexerSetOnly ()
2284                 {
2285                         string code = GeneratePropertyIndexer (MemberAttributes.Family,
2286                                 false, true, true, Options);
2287                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2288                                 "Public Structure Test1{0}" +
2289                                 "    {0}" +
2290                                 "    Protected Overridable Default WriteOnly Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
2291                                 "        Set{0}" +
2292                                 "        End Set{0}" +
2293                                 "    End Property{0}" +
2294                                 "End Structure{0}", NewLine), code);
2295                 }
2296
2297                 [Test]
2298                 public override void PropertyImplementationTypes ()
2299                 {
2300                         string code = GeneratePropertyImplementationTypes (Options);
2301                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2302                                 "Public Structure Test1{0}" +
2303                                 "    {0}" +
2304                                 "    Public Overridable Property Name() As Integer Implements IPolicy.Name , IWhatever.Name{0}" +
2305                                 "    End Property{0}" +
2306                                 "End Structure{0}", NewLine), code);
2307                 }
2308
2309                 [Test]
2310                 public override void PropertyOverloadsTest1 ()
2311                 {
2312                         string code = GeneratePropertyOverloads1 (Options);
2313                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2314                                 "Public Structure Test1{0}" +
2315                                 "    {0}" +
2316                                 "    Protected Overloads Overridable Property Name() As Integer{0}" +
2317                                 "    End Property{0}" +
2318                                 "End Structure{0}", NewLine), code);
2319                 }
2320
2321                 [Test]
2322                 public override void PropertyOverloadsTest2 ()
2323                 {
2324                         string code = GeneratePropertyOverloads2 (Options);
2325                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2326                                 "Public Structure Test1{0}" +
2327                                 "    {0}" +
2328                                 "    Public Overloads Overridable Property Name() As Integer{0}" +
2329                                 "    End Property{0}" +
2330                                 "    {0}" +
2331                                 "    Private Overloads Property Name(ByVal value1 As Object) As Integer{0}" +
2332                                 "    End Property{0}" +
2333                                 "End Structure{0}", NewLine), code);
2334                 }
2335
2336                 [Test]
2337                 public override void PropertyOverloadsTest3 ()
2338                 {
2339                         string code = GeneratePropertyOverloads3 (Options);
2340                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2341                                 "Public Structure Test1{0}" +
2342                                 "    {0}" +
2343                                 "    Public Overridable Property Name() As Integer{0}" +
2344                                 "    End Property{0}" +
2345                                 "    {0}" +
2346                                 "    Property System_Int32_Name(ByVal value1 As Object) As Integer Implements Integer.Name{0}" +
2347                                 "    End Property{0}" +
2348                                 "End Structure{0}", NewLine), code);
2349                 }
2350
2351                 [Test]
2352                 public override void PropertyPrivateImplementationType ()
2353                 {
2354                         string code = GeneratePropertyPrivateImplementationType (Options);
2355                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2356                                 "Public Structure Test1{0}" +
2357                                 "    {0}" +
2358                                 "    Overridable Property System_Int32_Item(ByVal value1 As Object) As Integer Implements Integer.Item{0}" +
2359                                 "    End Property{0}" +
2360                                 "End Structure{0}", NewLine), code);
2361                 }
2362
2363                 [Test]
2364                 public override void PropertyImplementationTypeOrder ()
2365                 {
2366                         string code = GeneratePropertyImplementationTypeOrder (Options);
2367                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2368                                 "Public Structure Test1{0}" +
2369                                 "    {0}" +
2370                                 "    Overridable Property System_Int32_Item(ByVal value1 As Object) As Integer Implements IPolicy.Item{0}" +
2371                                 "    End Property{0}" +
2372                                 "End Structure{0}", NewLine), code);
2373                 }
2374
2375                 [Test]
2376                 public override void PropertyNewSlotTest ()
2377                 {
2378                         string code = GeneratePropertyMembersType (MemberAttributes.Private |
2379                                 MemberAttributes.New, true, true, Options);
2380                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2381                                 "Public Structure Test1{0}" +
2382                                 "    {0}" +
2383                                 "    Private Shadows Property Name() As Integer{0}" +
2384                                 "        Get{0}" +
2385                                 "        End Get{0}" +
2386                                 "        Set{0}" +
2387                                 "        End Set{0}" +
2388                                 "    End Property{0}" +
2389                                 "End Structure{0}", NewLine), code);
2390                 }
2391
2392                 [Test]
2393                 public override void MethodMembersTypeTest1 ()
2394                 {
2395                         string code = GenerateMethodMembersType1 (Options);
2396                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2397                                 "Public Structure Test1{0}" +
2398                                 "    {0}" +
2399                                 "    <A(),  _{0}" +
2400                                 "     B()>  _{0}" +
2401                                 "    Private Sub (){0}" +
2402                                 "    End Sub{0}" +
2403                                 "End Structure{0}", NewLine), code);
2404                 }
2405
2406                 [Test]
2407                 public override void MethodMembersTypeTest2 ()
2408                 {
2409                         string code = GenerateMethodMembersType2 (Options);
2410                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2411                                 "Public Structure Test1{0}" +
2412                                 "    {0}" +
2413                                 "    Public Overridable Function Something(ByVal value1 As Object, ByVal value2 As Object, ByRef index As Integer, ByRef count As Integer) As Integer{0}" +
2414                                 "    End Function{0}" +
2415                                 "End Structure{0}", NewLine), code);
2416                 }
2417
2418                 [Test]
2419                 public override void MethodMembersTypeTest3 ()
2420                 {
2421                         string code = GenerateMethodMembersType3 (Options);
2422                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2423                                 "Public Structure Test1{0}" +
2424                                 "    {0}" +
2425                                 "    Public Overridable Function Something(<A(), B()> ByVal value As Object, <C(A1:=false, A2:=true), D()> ByRef __exception As Integer) As Integer{0}" +
2426                                 "    End Function{0}" +
2427                                 "End Structure{0}", NewLine), code);
2428                 }
2429
2430                 [Test]
2431                 public override void MethodImplementationTypes ()
2432                 {
2433                         string code = GenerateMethodImplementationTypes (Options);
2434                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2435                                 "Public Structure Test1{0}" +
2436                                 "    {0}" +
2437                                 "    Friend Overridable Function Execute() As Integer Implements IPolicy.Execute , IWhatever.Execute{0}" +
2438                                 "    End Function{0}" +
2439                                 "End Structure{0}", NewLine), code);
2440                 }
2441
2442                 [Test]
2443                 public override void MethodOverloadsTest1 ()
2444                 {
2445                         string code = GenerateMethodOverloads1 (Options);
2446                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2447                                 "Public Structure Test1{0}" +
2448                                 "    {0}" +
2449                                 "    Friend Overloads Overridable Function Execute() As Integer{0}" +
2450                                 "    End Function{0}" +
2451                                 "End Structure{0}", NewLine), code);
2452                 }
2453
2454                 [Test]
2455                 public override void MethodOverloadsTest2 ()
2456                 {
2457                         string code = GenerateMethodOverloads2 (Options);
2458                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2459                                 "Public Structure Test1{0}" +
2460                                 "    {0}" +
2461                                 "    Public Overloads Overridable Sub Execute(){0}" +
2462                                 "    End Sub{0}" +
2463                                 "    {0}" +
2464                                 "    Private Overloads Function Execute(ByVal value1 As Object) As Integer{0}" +
2465                                 "    End Function{0}" +
2466                                 "End Structure{0}", NewLine), code);
2467                 }
2468
2469                 [Test]
2470                 public override void MethodOverloadsTest3 ()
2471                 {
2472                         string code = GenerateMethodOverloads3 (Options);
2473                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2474                                 "Public Structure Test1{0}" +
2475                                 "    {0}" +
2476                                 "    Public Overridable Sub Execute(){0}" +
2477                                 "    End Sub{0}" +
2478                                 "    {0}" +
2479                                 "    Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements Integer.Execute{0}" +
2480                                 "    End Function{0}" +
2481                                 "End Structure{0}", NewLine), code);
2482                 }
2483
2484                 [Test]
2485                 public override void MethodPrivateImplementationType ()
2486                 {
2487                         string code = GenerateMethodPrivateImplementationType (Options);
2488                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2489                                 "Public Structure Test1{0}" +
2490                                 "    {0}" +
2491                                 "    Overridable Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements Integer.Execute{0}" +
2492                                 "    End Function{0}" +
2493                                 "End Structure{0}", NewLine), code);
2494                 }
2495
2496                 [Test]
2497                 public override void MethodImplementationTypeOrder ()
2498                 {
2499                         string code = GenerateMethodImplementationTypeOrder (Options);
2500                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2501                                 "Public Structure Test1{0}" +
2502                                 "    {0}" +
2503                                 "    Overridable Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements IPolicy.Execute{0}" +
2504                                 "    End Function{0}" +
2505                                 "End Structure{0}", NewLine), code);
2506                 }
2507
2508                 [Test]
2509                 public override void MethodParamArrayAttribute ()
2510                 {
2511                         string code = GenerateMethodParamArrayAttribute (Options);
2512                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2513                                 "Public Structure Test1{0}" +
2514                                 "    {0}" +
2515                                 "    Public Overridable Function Something(<A(), System.ParamArrayAttribute(), B()> ByRef value As Object, <C()> ByRef __exception As Integer) As Integer{0}" +
2516                                 "    End Function{0}" +
2517                                 "End Structure{0}", NewLine), code);
2518                 }
2519
2520                 [Test]
2521                 public override void MethodReturnTypeAttributes ()
2522                 {
2523                         string code = GenerateMethodReturnTypeAttributes (Options);
2524                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2525                                 "Public Structure Test1{0}" +
2526                                 "    {0}" +
2527                                 "    <A(),  _{0}" +
2528                                 "     B(),  _{0}" +
2529                                 "     System.ParamArrayAttribute()>  _{0}" +
2530                                 "    Public Overridable Function Execute() As <C(A1:=false, A2:=true), System.ParamArrayAttribute(), D()> Integer{0}" +
2531                                 "    End Function{0}" +
2532                                 "End Structure{0}", NewLine), code);
2533                 }
2534
2535                 [Test]
2536                 public override void MethodNewSlotTest ()
2537                 {
2538                         string code = GenerateMethodNewSlot (Options);
2539                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2540                                 "Public Structure Test1{0}" +
2541                                 "    {0}" +
2542                                 "    Public Shadows Overridable Function Execute() As Integer{0}" +
2543                                 "    End Function{0}" +
2544                                 "End Structure{0}", NewLine), code);
2545                 }
2546
2547                 [Test]
2548                 public override void ConstructorAttributesTest ()
2549                 {
2550                         // FIXME: updated to reflect mbas workaround
2551                         string code = GenerateConstructorAttributes (Options);
2552                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2553                                 "Public Structure Test1{0}" +
2554                                 "    {0}" +
2555                                 "    <A(),  _{0}" +
2556                                 "     B()>  _{0}" +
2557                                 "    Private Sub New(){0}" +
2558                                 "    End Sub{0}" +
2559                                 "End Structure{0}", NewLine), code);
2560                 }
2561
2562                 [Test]
2563                 public override void ConstructorParametersTest ()
2564                 {
2565                         // FIXME: updated to reflect mbas workaround
2566                         string code = GenerateConstructorParameters (Options);
2567                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2568                                 "Public Structure Test1{0}" +
2569                                 "    {0}" +
2570                                 "    Public Sub New(ByVal value1 As Object, ByVal value2 As Object, ByRef index As Integer, ByRef count As Integer){0}" +
2571                                 "    End Sub{0}" +
2572                                 "End Structure{0}", NewLine), code);
2573                 }
2574
2575                 [Test]
2576                 public override void ConstructorParameterAttributesTest ()
2577                 {
2578                         // FIXME: updated to reflect mbas workaround
2579                         string code = GenerateConstructorParameterAttributes (Options);
2580                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2581                                 "Public Structure Test1{0}" +
2582                                 "    {0}" +
2583                                 "    Private Sub New(<A(), B()> ByVal value As Object, <C(A1:=false, A2:=true), D()> ByRef index As Integer){0}" +
2584                                 "    End Sub{0}" +
2585                                 "End Structure{0}", NewLine), code);
2586                 }
2587
2588                 [Test]
2589                 public override void BaseConstructorSingleArg ()
2590                 {
2591                         string code = GenerateBaseConstructor (false, Options);
2592                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2593                                 "Public Structure Test1{0}" +
2594                                 "    {0}" +
2595                                 "    Protected Sub New(ByVal value1 As Object, ByRef value2 As Integer){0}" +
2596                                 "        MyBase.New(value1){0}" +
2597                                 "    End Sub{0}" +
2598                                 "End Structure{0}", NewLine), code);
2599                 }
2600
2601                 [Test]
2602                 public override void BaseConstructorMultipleArgs ()
2603                 {
2604                         string code = GenerateBaseConstructor (true, Options);
2605                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2606                                 "Public Structure Test1{0}" +
2607                                 "    {0}" +
2608                                 "    Protected Sub New(ByVal value1 As Object, ByRef value2 As Integer){0}" +
2609                                 "        MyBase.New(value1, value2){0}" +
2610                                 "    End Sub{0}" +
2611                                 "End Structure{0}", NewLine), code);
2612                 }
2613
2614                 [Test]
2615                 public override void ChainedConstructorSingleArg ()
2616                 {
2617                         string code = GenerateChainedConstructor (false, Options);
2618                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2619                                 "Public Structure Test1{0}" +
2620                                 "    {0}" +
2621                                 "    Public Sub New(ByVal value1 As Object, ByRef value2 As Integer){0}" +
2622                                 "        Me.New(value1){0}" +
2623                                 "    End Sub{0}" +
2624                                 "End Structure{0}", NewLine), code);
2625                 }
2626
2627                 [Test]
2628                 public override void ChainedConstructorMultipleArgs ()
2629                 {
2630                         string code = GenerateChainedConstructor (true, Options);
2631                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2632                                 "Public Structure Test1{0}" +
2633                                 "    {0}" +
2634                                 "    Public Sub New(ByVal value1 As Object, ByRef value2 As Integer){0}" +
2635                                 "        Me.New(value1, value2){0}" +
2636                                 "    End Sub{0}" +
2637                                 "End Structure{0}", NewLine), code);
2638                 }
2639
2640                 [Test]
2641                 public override void TypeConstructorTest ()
2642                 {
2643                         string code = GenerateTypeConstructor (Options);
2644                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2645                                 "Public Structure Test1{0}" +
2646                                 "    {0}" +
2647                                 "    <A(),  _{0}" +
2648                                 "     B()>  _{0}" +
2649                                 "    Shared Sub New(){0}" +
2650                                 "    End Sub{0}" +
2651                                 "End Structure{0}", NewLine), code);
2652                 }
2653
2654                 [Test]
2655                 public override void EntryPointMethodTest ()
2656                 {
2657                         string code = GenerateEntryPointMethod (Options);
2658                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2659                                 "Public Structure Test1{0}" +
2660                                 "    {0}" +
2661                                 "    <A()>  _{0}" +
2662                                 "    Public Shared Sub Main(){0}" +
2663                                 "        Dim x As Test.InnerType{0}" +
2664                                 "    End Sub{0}" +
2665                                 "End Structure{0}", NewLine), code);
2666                 }
2667                 
2668                 [Test]
2669                 public override void PartialTypeTest ()
2670                 {
2671                         string code = GeneratePartialType (Options);
2672                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2673                                 "Partial Public Structure Test1{0}" +
2674                                 "End Structure{0}", NewLine), code);
2675                 }
2676         }
2677
2678         [TestFixture]
2679         public class CodeGeneratorFromTypeTest_Enum : CodeGeneratorFromTypeTestBase
2680         {
2681                 private CodeTypeDeclaration _typeDeclaration;
2682                 private ICodeGenerator _codeGenerator;
2683
2684                 protected override ICodeGenerator CodeGenerator
2685                 {
2686                         get { return _codeGenerator; }
2687                 }
2688
2689                 protected override CodeTypeDeclaration TypeDeclaration
2690                 {
2691                         get { return _typeDeclaration; }
2692                 }
2693
2694                 [SetUp]
2695                 public override void SetUp ()
2696                 {
2697                         base.SetUp ();
2698                         _typeDeclaration = new CodeTypeDeclaration ();
2699                         _typeDeclaration.IsEnum = true;
2700
2701                         CodeDomProvider provider = new VBCodeProvider ();
2702                         _codeGenerator = provider.CreateGenerator ();
2703                 }
2704
2705                 [Test]
2706                 public override void DefaultTypeTest ()
2707                 {
2708                         string code = GenerateDefaultType (Options);
2709                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2710                                 "Public Enum {0}" +
2711                                 "End Enum{0}", NewLine), code);
2712                 }
2713
2714                 [Test]
2715                 [ExpectedException (typeof (NullReferenceException))]
2716                 public override void NullTypeTest ()
2717                 {
2718                         GenerateNullType (Options);
2719                 }
2720
2721                 [Test]
2722                 public override void SimpleTypeTest ()
2723                 {
2724                         string code = GenerateSimpleType (Options);
2725                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2726                                 "Public Enum Test1{0}" +
2727                                 "End Enum{0}", NewLine), code);
2728                 }
2729
2730                 [Test]
2731                 public override void DerivedTypeTest ()
2732                 {
2733                         string code = GenerateDerivedType (Options);
2734                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2735                                 "Friend Enum Test1 As Integer{0}" +
2736                                 "End Enum{0}", NewLine), code);
2737                 }
2738
2739                 [Test]
2740                 public override void AttributesAndTypeTest ()
2741                 {
2742                         string code = GenerateAttributesAndType (Options);
2743                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2744                                 "<A(),  _{0}" +
2745                                 " B()>  _{0}" + 
2746                                 "Public Enum Test1{0}" +
2747                                 "End Enum{0}", NewLine), code);
2748                 }
2749
2750                 [Test]
2751                 public override void EventMembersTypeTest1 ()
2752                 {
2753                         string code = GenerateEventMembersType1 (Options);
2754                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2755                                 "Public Enum Test1{0}" +
2756                                 "    {0}" +
2757                                 "End Enum{0}", NewLine), code);
2758                 }
2759
2760                 [Test]
2761                 public override void EventMembersTypeTest2 ()
2762                 {
2763                         string code = GenerateEventMembersType2 (Options);
2764                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2765                                 "Public Enum Test1{0}" +
2766                                 "    {0}" +
2767                                 "End Enum{0}", NewLine), code);
2768                 }
2769
2770                 [Test]
2771                 public override void EventImplementationTypes ()
2772                 {
2773                         string code = GenerateEventImplementationTypes (Options);
2774                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2775                                 "Public Enum Test1{0}" +
2776                                 "    {0}" +
2777                                 "End Enum{0}", NewLine), code);
2778                 }
2779
2780                 [Test]
2781                 public override void EventPrivateImplementationType ()
2782                 {
2783                         string code = GenerateEventPrivateImplementationType (Options);
2784                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2785                                 "Public Enum Test1{0}" +
2786                                 "    {0}" +
2787                                 "End Enum{0}", NewLine), code);
2788                 }
2789
2790                 [Test]
2791                 public override void EventImplementationTypeOrder ()
2792                 {
2793                         string code = GenerateEventImplementationTypeOrder (Options);
2794                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2795                                 "Public Enum Test1{0}" +
2796                                 "    {0}" +
2797                                 "End Enum{0}", NewLine), code);
2798                 }
2799
2800                 [Test]
2801                 public override void FieldMembersAttributesTest ()
2802                 {
2803                         string code = GenerateFieldMembersAttributes (Options);
2804                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2805                                 "Public Enum Test1{0}" +
2806                                 "    {0}" +
2807                                 "    <A(),  _{0}" +
2808                                 "     B()>  _{0}" +
2809                                 "    {0}" +
2810                                 "End Enum{0}", NewLine), code);
2811                 }
2812
2813                 [Test]
2814                 public override void FieldMembersTypeTest ()
2815                 {
2816                         string code = GenerateFieldMembersType (MemberAttributes.Public, Options);
2817                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2818                                 "Public Enum Test1{0}" +
2819                                 "    {0}" +
2820                                 "    Name = 2{0}" +
2821                                 "End Enum{0}", NewLine), code);
2822                 }
2823
2824                 [Test]
2825                 public override void FieldNewSlotTest ()
2826                 {
2827                         string code = GenerateFieldMembersType (MemberAttributes.Assembly |
2828                                 MemberAttributes.New, Options);
2829                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2830                                 "Public Enum Test1{0}" +
2831                                 "    {0}" +
2832                                 "    Name = 2{0}" +
2833                                 "End Enum{0}", NewLine), code);
2834                 }
2835
2836                 [Test]
2837                 public override void PropertyMembersTypeTest1 ()
2838                 {
2839                         string code = GeneratePropertyMembersAttributes (Options);
2840                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2841                                 "Public Enum Test1{0}" +
2842                                 "    {0}" +
2843                                 "End Enum{0}", NewLine), code);
2844                 }
2845
2846                 [Test]
2847                 public override void PropertyMembersTypeTest2 ()
2848                 {
2849                         string code = GeneratePropertyMembersType (MemberAttributes.Public,
2850                                 false, false, Options);
2851                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2852                                 "Public Enum Test1{0}" +
2853                                 "    {0}" +
2854                                 "End Enum{0}", NewLine), code);
2855                 }
2856
2857                 [Test]
2858                 public override void PropertyMembersTypeGetOnly ()
2859                 {
2860                         string code = GeneratePropertyMembersType (MemberAttributes.Family,
2861                                 true, false, Options);
2862                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2863                                 "Public Enum Test1{0}" +
2864                                 "    {0}" +
2865                                 "End Enum{0}", NewLine), code);
2866                 }
2867
2868                 [Test]
2869                 public override void PropertyMembersTypeSetOnly ()
2870                 {
2871                         string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
2872                                 false, true, Options);
2873                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2874                                 "Public Enum Test1{0}" +
2875                                 "    {0}" +
2876                                 "End Enum{0}", NewLine), code);
2877                 }
2878
2879                 [Test]
2880                 public override void PropertyMembersTypeGetSet ()
2881                 {
2882                         string code = GeneratePropertyMembersType (MemberAttributes.Family,
2883                                 true, true, Options);
2884                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2885                                 "Public Enum Test1{0}" +
2886                                 "    {0}" +
2887                                 "End Enum{0}", NewLine), code);
2888                 }
2889
2890                 [Test]
2891                 public override void PropertyMembersTypeFamilyOrAssembly ()
2892                 {
2893                         string code = GeneratePropertyMembersType (MemberAttributes.FamilyOrAssembly,
2894                                 false, false, Options);
2895                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2896                                 "Public Enum Test1{0}" +
2897                                 "    {0}" +
2898                                 "End Enum{0}", NewLine), code);
2899                 }
2900
2901                 [Test]
2902                 public override void PropertyMembersTypeAssembly ()
2903                 {
2904                         string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
2905                                 false, false, Options);
2906                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2907                                 "Public Enum Test1{0}" +
2908                                 "    {0}" +
2909                                 "End Enum{0}", NewLine), code);
2910                 }
2911
2912                 [Test]
2913                 public override void PropertyParametersTest ()
2914                 {
2915                         string code = GeneratePropertyParameters (Options);
2916                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2917                                 "Public Enum Test1{0}" +
2918                                 "    {0}" +
2919                                 "End Enum{0}", NewLine), code);
2920                 }
2921
2922                 [Test]
2923                 public override void PropertyIndexerTest1 ()
2924                 {
2925                         string code = GeneratePropertyIndexer (MemberAttributes.Public,
2926                                 false, false, true, Options);
2927                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2928                                 "Public Enum Test1{0}" +
2929                                 "    {0}" +
2930                                 "End Enum{0}", NewLine), code);
2931                 }
2932
2933                 [Test]
2934                 public override void PropertyIndexerTest2 ()
2935                 {
2936                         string code = GeneratePropertyIndexer (MemberAttributes.Public,
2937                                 false, false, false, Options);
2938                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2939                                 "Public Enum Test1{0}" +
2940                                 "    {0}" +
2941                                 "End Enum{0}", NewLine), code);
2942                 }
2943
2944                 [Test]
2945                 public override void PropertyIndexerGetOnly ()
2946                 {
2947                         string code = GeneratePropertyIndexer (MemberAttributes.Family,
2948                                 true, false, true, Options);
2949                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2950                                 "Public Enum Test1{0}" +
2951                                 "    {0}" +
2952                                 "End Enum{0}", NewLine), code);
2953                 }
2954
2955                 [Test]
2956                 public override void PropertyIndexerSetOnly ()
2957                 {
2958                         string code = GeneratePropertyIndexer (MemberAttributes.Family,
2959                                 false, true, true, Options);
2960                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2961                                 "Public Enum Test1{0}" +
2962                                 "    {0}" +
2963                                 "End Enum{0}", NewLine), code);
2964                 }
2965
2966                 [Test]
2967                 public override void PropertyImplementationTypes ()
2968                 {
2969                         string code = GeneratePropertyImplementationTypes (Options);
2970                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2971                                 "Public Enum Test1{0}" +
2972                                 "    {0}" +
2973                                 "End Enum{0}", NewLine), code);
2974                 }
2975
2976                 [Test]
2977                 public override void PropertyOverloadsTest1 ()
2978                 {
2979                         string code = GeneratePropertyOverloads1 (Options);
2980                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2981                                 "Public Enum Test1{0}" +
2982                                 "    {0}" +
2983                                 "End Enum{0}", NewLine), code);
2984                 }
2985
2986                 [Test]
2987                 public override void PropertyOverloadsTest2 ()
2988                 {
2989                         string code = GeneratePropertyOverloads2 (Options);
2990                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2991                                 "Public Enum Test1{0}" +
2992                                 "    {0}" +
2993                                 "    {0}" +
2994                                 "End Enum{0}", NewLine), code);
2995                 }
2996
2997                 [Test]
2998                 public override void PropertyOverloadsTest3 ()
2999                 {
3000                         string code = GeneratePropertyOverloads3 (Options);
3001                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3002                                 "Public Enum Test1{0}" +
3003                                 "    {0}" +
3004                                 "    {0}" +
3005                                 "End Enum{0}", NewLine), code);
3006                 }
3007
3008                 [Test]
3009                 public override void PropertyPrivateImplementationType ()
3010                 {
3011                         string code = GeneratePropertyPrivateImplementationType (Options);
3012                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3013                                 "Public Enum Test1{0}" +
3014                                 "    {0}" +
3015                                 "End Enum{0}", NewLine), code);
3016                 }
3017
3018                 [Test]
3019                 public override void PropertyImplementationTypeOrder ()
3020                 {
3021                         string code = GeneratePropertyImplementationTypeOrder (Options);
3022                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3023                                 "Public Enum Test1{0}" +
3024                                 "    {0}" +
3025                                 "End Enum{0}", NewLine), code);
3026                 }
3027
3028                 [Test]
3029                 public override void PropertyNewSlotTest ()
3030                 {
3031                         string code = GeneratePropertyMembersType (MemberAttributes.Private |
3032                                 MemberAttributes.New, true, true, Options);
3033                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3034                                 "Public Enum Test1{0}" +
3035                                 "    {0}" +
3036                                 "End Enum{0}", NewLine), code);
3037                 }
3038
3039                 [Test]
3040                 public override void MethodMembersTypeTest1 ()
3041                 {
3042                         string code = GenerateMethodMembersType1 (Options);
3043                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3044                                 "Public Enum Test1{0}" +
3045                                 "    {0}" +
3046                                 "End Enum{0}", NewLine), code);
3047                 }
3048
3049                 [Test]
3050                 public override void MethodMembersTypeTest2 ()
3051                 {
3052                         string code = GenerateMethodMembersType2 (Options);
3053                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3054                                 "Public Enum Test1{0}" +
3055                                 "    {0}" +
3056                                 "End Enum{0}", NewLine), code);
3057                 }
3058
3059                 [Test]
3060                 public override void MethodMembersTypeTest3 ()
3061                 {
3062                         string code = GenerateMethodMembersType3 (Options);
3063                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3064                                 "Public Enum Test1{0}" +
3065                                 "    {0}" +
3066                                 "End Enum{0}", NewLine), code);
3067                 }
3068
3069                 [Test]
3070                 public override void MethodImplementationTypes ()
3071                 {
3072                         string code = GenerateMethodImplementationTypes (Options);
3073                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3074                                 "Public Enum Test1{0}" +
3075                                 "    {0}" +
3076                                 "End Enum{0}", NewLine), code);
3077                 }
3078
3079                 [Test]
3080                 public override void MethodOverloadsTest1 ()
3081                 {
3082                         string code = GenerateMethodOverloads1 (Options);
3083                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3084                                 "Public Enum Test1{0}" +
3085                                 "    {0}" +
3086                                 "End Enum{0}", NewLine), code);
3087                 }
3088
3089                 [Test]
3090                 public override void MethodOverloadsTest2 ()
3091                 {
3092                         string code = GenerateMethodOverloads2 (Options);
3093                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3094                                 "Public Enum Test1{0}" +
3095                                 "    {0}" +
3096                                 "    {0}" +
3097                                 "End Enum{0}", NewLine), code);
3098                 }
3099
3100                 [Test]
3101                 public override void MethodOverloadsTest3 ()
3102                 {
3103                         string code = GenerateMethodOverloads3 (Options);
3104                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3105                                 "Public Enum Test1{0}" +
3106                                 "    {0}" +
3107                                 "    {0}" +
3108                                 "End Enum{0}", NewLine), code);
3109                 }
3110
3111                 [Test]
3112                 public override void MethodPrivateImplementationType ()
3113                 {
3114                         string code = GenerateMethodPrivateImplementationType (Options);
3115                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3116                                 "Public Enum Test1{0}" +
3117                                 "    {0}" +
3118                                 "End Enum{0}", NewLine), code);
3119                 }
3120
3121                 [Test]
3122                 public override void MethodImplementationTypeOrder ()
3123                 {
3124                         string code = GenerateMethodImplementationTypeOrder (Options);
3125                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3126                                 "Public Enum Test1{0}" +
3127                                 "    {0}" +
3128                                 "End Enum{0}", NewLine), code);
3129                 }
3130
3131                 [Test]
3132                 public override void MethodParamArrayAttribute ()
3133                 {
3134                         string code = GenerateMethodParamArrayAttribute (Options);
3135                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3136                                 "Public Enum Test1{0}" +
3137                                 "    {0}" +
3138                                 "End Enum{0}", NewLine), code);
3139                 }
3140
3141                 [Test]
3142                 public override void MethodReturnTypeAttributes ()
3143                 {
3144                         string code = GenerateMethodReturnTypeAttributes (Options);
3145                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3146                                 "Public Enum Test1{0}" +
3147                                 "    {0}" +
3148                                 "End Enum{0}", NewLine), code);
3149                 }
3150
3151                 [Test]
3152                 public override void MethodNewSlotTest ()
3153                 {
3154                         string code = GenerateMethodNewSlot (Options);
3155                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3156                                 "Public Enum Test1{0}" +
3157                                 "    {0}" +
3158                                 "End Enum{0}", NewLine), code);
3159                 }
3160
3161                 [Test]
3162                 public override void ConstructorAttributesTest ()
3163                 {
3164                         string code = GenerateConstructorAttributes (Options);
3165                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3166                                 "Public Enum Test1{0}" +
3167                                 "    {0}" +
3168                                 "End Enum{0}", NewLine), code);
3169                 }
3170
3171                 [Test]
3172                 public override void ConstructorParametersTest ()
3173                 {
3174                         string code = GenerateConstructorParameters (Options);
3175                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3176                                 "Public Enum Test1{0}" +
3177                                 "    {0}" +
3178                                 "End Enum{0}", NewLine), code);
3179                 }
3180
3181                 [Test]
3182                 public override void ConstructorParameterAttributesTest ()
3183                 {
3184                         string code = GenerateConstructorParameterAttributes (Options);
3185                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3186                                 "Public Enum Test1{0}" +
3187                                 "    {0}" +
3188                                 "End Enum{0}", NewLine), code);
3189                 }
3190
3191                 [Test]
3192                 public override void BaseConstructorSingleArg ()
3193                 {
3194                         string code = GenerateBaseConstructor (false, Options);
3195                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3196                                 "Public Enum Test1{0}" +
3197                                 "    {0}" +
3198                                 "End Enum{0}", NewLine), code);
3199                 }
3200
3201                 [Test]
3202                 public override void BaseConstructorMultipleArgs ()
3203                 {
3204                         string code = GenerateBaseConstructor (true, Options);
3205                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3206                                 "Public Enum Test1{0}" +
3207                                 "    {0}" +
3208                                 "End Enum{0}", NewLine), code);
3209                 }
3210
3211                 [Test]
3212                 public override void ChainedConstructorSingleArg ()
3213                 {
3214                         string code = GenerateChainedConstructor (false, Options);
3215                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3216                                 "Public Enum Test1{0}" +
3217                                 "    {0}" +
3218                                 "End Enum{0}", NewLine), code);
3219                 }
3220
3221                 [Test]
3222                 public override void ChainedConstructorMultipleArgs ()
3223                 {
3224                         string code = GenerateChainedConstructor (true, Options);
3225                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3226                                 "Public Enum Test1{0}" +
3227                                 "    {0}" +
3228                                 "End Enum{0}", NewLine), code);
3229                 }
3230
3231                 [Test]
3232                 public override void TypeConstructorTest ()
3233                 {
3234                         string code = GenerateTypeConstructor (Options);
3235                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3236                                 "Public Enum Test1{0}" +
3237                                 "    {0}" +
3238                                 "End Enum{0}", NewLine), code);
3239                 }
3240
3241                 [Test]
3242                 public override void EntryPointMethodTest ()
3243                 {
3244                         string code = GenerateEntryPointMethod (Options);
3245                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3246                                 "Public Enum Test1{0}" +
3247                                 "    {0}" +
3248                                 "    <A()>  _{0}" +
3249                                 "    Public Shared Sub Main(){0}" +
3250                                 "        Dim x As Test.InnerType{0}" +
3251                                 "    End Sub{0}" +
3252                                 "End Enum{0}", NewLine), code);
3253                 }
3254                 
3255                 [Test]
3256                 public override void PartialTypeTest ()
3257                 {
3258                         string code = GeneratePartialType (Options);
3259                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3260                                 "Partial Public Enum Test1{0}" +
3261                                 "End Enum{0}", NewLine), code);
3262                 }
3263         }
3264 }