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