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