* CodeGeneratorFromTypeTest.cs: Added test for ReturnTypeCustomAttributes.
[mono.git] / mcs / class / System / Test / Microsoft.CSharp / CodeGeneratorFromTypeTest.cs
1 //
2 // Microsoft.CSharp.* Test Cases
3 //
4 // Authors:
5 //      Erik LeBel (eriklebel@yahoo.ca)
6 //
7 // (c) 2003 Erik LeBel
8 //
9 using System;
10 using System.Globalization;
11 using System.Text;
12 using System.CodeDom;
13 using System.CodeDom.Compiler;
14
15 using NUnit.Framework;
16
17 namespace MonoTests.Microsoft.CSharp
18 {
19         ///
20         /// <summary>
21         ///     Test ICodeGenerator's GenerateCodeFromType, along with a 
22         ///     minimal set CodeDom components.
23         /// </summary>
24         ///
25         [TestFixture]
26         public class CodeGeneratorFromTypeTest: CodeGeneratorTestBase
27         {
28                 CodeTypeDeclaration type = null;
29
30                 [SetUp]
31                 public void Init ()
32                 {
33                         InitBase ();
34                         type = new CodeTypeDeclaration ();
35                 }
36                 
37                 protected override void Generate ()
38                 {
39                         generator.GenerateCodeFromType (type, writer, options);
40                         writer.Close ();
41                 }
42                 
43                 [Test]
44                 public void DefaultTypeTest ()
45                 {
46                         Generate ();
47                         Assert.AreEqual ("public class  {\n}\n", Code);
48                 }
49
50                 [Test]
51                 [ExpectedException (typeof (NullReferenceException))]
52                 public void NullTypeTest ()
53                 {
54                         type = null;
55                         Generate ();
56                 }
57
58                 [Test]
59                 public void SimpleTypeTest ()
60                 {
61                         type.Name = "Test1";
62                         Generate ();
63                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
64                                 "public class Test1 {{{0}}}{0}", writer.NewLine), Code);
65                 }
66
67                 [Test]
68                 public void AttributesAndTypeTest ()
69                 {
70                         type.Name = "Test1";
71
72                         CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
73                         attrDec.Name = "A";
74                         type.CustomAttributes.Add (attrDec);
75
76                         attrDec = new CodeAttributeDeclaration ();
77                         attrDec.Name = "B";
78                         type.CustomAttributes.Add (attrDec);
79
80                         Generate ();
81                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
82                                 "[A()]{0}"
83                                 + "[B()]{0}"
84                                 + "public class Test1 {{{0}"
85                                 + "}}{0}", writer.NewLine), Code);
86                 }
87
88                 [Test]
89                 public void EventMembersTypeTest1 ()
90                 {
91                         type.Name = "Test1";
92
93                         CodeMemberEvent evt = new CodeMemberEvent ();
94
95                         CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
96                         attrDec.Name = "A";
97                         evt.CustomAttributes.Add (attrDec);
98
99                         attrDec = new CodeAttributeDeclaration ();
100                         attrDec.Name = "B";
101                         evt.CustomAttributes.Add (attrDec);
102
103                         type.Members.Add (evt);
104
105                         Generate ();
106                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
107                                 "public class Test1 {{{0}"
108                                 + "    {0}"
109                                 + "    [A()]{0}"
110                                 + "    [B()]{0}"
111                                 + "    private event void ;{0}"
112                                 + "}}{0}", writer.NewLine), Code);
113                 }
114
115                 [Test]
116                 public void EventMembersTypeTest2 ()
117                 {
118                         type.Name = "Test1";
119
120                         CodeMemberEvent evt = new CodeMemberEvent ();
121                         evt.Name = "OnClick";
122                         evt.Attributes = MemberAttributes.Public | MemberAttributes.Override
123                                 | MemberAttributes.Static | MemberAttributes.Abstract |
124                                 MemberAttributes.New;
125                         evt.Type = new CodeTypeReference (typeof (int));
126                         // C# does not support Implementation Types, so this should be ignored
127                         evt.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
128                         type.Members.Add (evt);
129
130                         Generate ();
131                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
132                                 "public class Test1 {{{0}"
133                                 + "    {0}"
134                                 + "    public event int OnClick;{0}"
135                                 + "}}{0}", writer.NewLine), Code);
136                 }
137
138                 [Test]
139                 public void EventImplementationTypes ()
140                 {
141                         type.Name = "Test1";
142
143                         CodeMemberEvent evt = new CodeMemberEvent ();
144                         evt.Name = "Click";
145                         evt.Attributes = MemberAttributes.FamilyAndAssembly;
146                         evt.Type = new CodeTypeReference (typeof (int));
147                         evt.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
148                         evt.ImplementationTypes.Add (new CodeTypeReference ("IWhatever"));
149                         type.Members.Add (evt);
150
151                         Generate ();
152                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
153                                 "public class Test1 {{{0}"
154                                 + "    {0}"
155 #if NET_2_0
156                                 + "    internal event int Click;{0}"
157 #else
158                                 + "    /*FamANDAssem*/ internal event int Click;{0}"
159 #endif
160                                 + "}}{0}", writer.NewLine), Code);
161                 }
162
163                 /// <summary>
164                 /// Ensure no access modifiers are output if PrivateImplementationType
165                 /// is set.
166                 /// </summary>
167                 [Test]
168                 public void EventPrivateImplementationType ()
169                 {
170                         type.Name = "Test1";
171
172                         CodeMemberEvent evt = new CodeMemberEvent ();
173                         evt.Name = "Click";
174                         evt.Attributes = MemberAttributes.Family | MemberAttributes.Overloaded;
175                         evt.Type = new CodeTypeReference (typeof (int));
176                         evt.PrivateImplementationType = new CodeTypeReference (typeof (int));
177                         type.Members.Add (evt);
178
179                         Generate ();
180                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
181                                 "public class Test1 {{{0}"
182                                 + "    {0}"
183                                 + "    event int System.Int32.Click;{0}"
184                                 + "}}{0}", writer.NewLine), Code);
185                 }
186
187                 [Test]
188                 public void EventImplementationTypeOrder ()
189                 {
190                         type.Name = "Test1";
191
192                         CodeMemberEvent evt = new CodeMemberEvent ();
193                         evt.Name = "Click";
194                         evt.Attributes = MemberAttributes.Public | MemberAttributes.Overloaded;
195                         evt.Type = new CodeTypeReference (typeof (int));
196                         evt.PrivateImplementationType = new CodeTypeReference (typeof (int));
197                         evt.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
198                         type.Members.Add (evt);
199
200                         Generate ();
201                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
202                                 "public class Test1 {{{0}"
203                                 + "    {0}"
204                                 + "    event int System.Int32.Click;{0}"
205                                 + "}}{0}", writer.NewLine), Code);
206                 }
207
208                 [Test]
209                 public void FieldMembersTypeTest1 ()
210                 {
211                         type.Name = "Test1";
212
213                         CodeMemberField fld = new CodeMemberField ();
214
215                         CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
216                         attrDec.Name = "A";
217                         fld.CustomAttributes.Add (attrDec);
218
219                         attrDec = new CodeAttributeDeclaration ();
220                         attrDec.Name = "B";
221                         fld.CustomAttributes.Add (attrDec);
222
223                         type.Members.Add (fld);
224
225                         Generate ();
226                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
227                                 "public class Test1 {{{0}"
228                                 + "    {0}"
229                                 + "    [A()]{0}"
230                                 + "    [B()]{0}"
231                                 + "    private void ;{0}"
232                                 + "}}{0}", writer.NewLine), Code);
233                 }
234
235                 [Test]
236                 public void FieldMembersTypeTest2 ()
237                 {
238                         type.Name = "Test1";
239
240                         CodeMemberField fld = new CodeMemberField ();
241                         fld.Name = "Name";
242                         fld.Attributes = MemberAttributes.Public;
243                         fld.Type = new CodeTypeReference (typeof (int));
244                         type.Members.Add (fld);
245
246                         Generate ();
247                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
248                                 "public class Test1 {{{0}"
249                                 + "    {0}"
250                                 + "    public int Name;{0}"
251                                 + "}}{0}", writer.NewLine), Code);
252                 }
253
254                 [Test]
255                 public void PropertyMembersTypeTest1 ()
256                 {
257                         type.Name = "Test1";
258
259                         CodeMemberProperty property = new CodeMemberProperty ();
260
261                         CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
262                         attrDec.Name = "A";
263                         property.CustomAttributes.Add (attrDec);
264
265                         attrDec = new CodeAttributeDeclaration ();
266                         attrDec.Name = "B";
267                         property.CustomAttributes.Add (attrDec);
268
269                         type.Members.Add (property);
270
271                         Generate ();
272                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
273                                 "public class Test1 {{{0}"
274                                 + "    {0}"
275                                 + "    [A()]{0}"
276                                 + "    [B()]{0}"
277                                 + "    private void  {{{0}"
278                                 + "    }}{0}"
279                                 + "}}{0}", writer.NewLine), Code);
280                 }
281
282                 [Test]
283                 public void PropertyMembersTypeTest2 ()
284                 {
285                         type.Name = "Test1";
286
287                         CodeMemberProperty property = new CodeMemberProperty ();
288                         property.Name = "Name";
289                         property.Attributes = MemberAttributes.Public;
290                         property.Type = new CodeTypeReference (typeof (int));
291                         // C# does not support Implementation Types, so this should be ignored
292                         property.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
293                         type.Members.Add (property);
294
295                         Generate ();
296                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
297                                 "public class Test1 {{{0}"
298                                 + "    {0}"
299                                 + "    public virtual int Name {{{0}"
300                                 + "    }}{0}"
301                                 + "}}{0}", writer.NewLine), Code);
302                 }
303
304                 [Test]
305                 public void PropertyMembersTypeGetOnly ()
306                 {
307                         type.Name = "Test1";
308
309                         CodeMemberProperty property = new CodeMemberProperty ();
310                         property.Name = "Name";
311                         property.Attributes = MemberAttributes.Family;
312                         property.HasGet = true;
313                         property.Type = new CodeTypeReference (typeof (int));
314                         type.Members.Add (property);
315
316                         Generate ();
317                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
318                                 "public class Test1 {{{0}"
319                                 + "    {0}"
320                                 + "    protected virtual int Name {{{0}"
321                                 + "        get {{{0}"
322                                 + "        }}{0}"
323                                 + "    }}{0}"
324                                 + "}}{0}", writer.NewLine), Code);
325                 }
326
327                 [Test]
328                 public void PropertyMembersTypeSetOnly ()
329                 {
330                         type.Name = "Test1";
331
332                         CodeMemberProperty property = new CodeMemberProperty ();
333                         property.Name = "Name";
334                         property.Attributes = MemberAttributes.FamilyOrAssembly;
335                         property.HasSet = true;
336                         property.Type = new CodeTypeReference (typeof (int));
337                         type.Members.Add (property);
338
339                         Generate ();
340                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
341                                 "public class Test1 {{{0}"
342                                 + "    {0}"
343                                 + "    protected internal int Name {{{0}"
344                                 + "        set {{{0}"
345                                 + "        }}{0}"
346                                 + "    }}{0}"
347                                 + "}}{0}", writer.NewLine), Code);
348                 }
349
350                 [Test]
351                 public void PropertyMembersTypeGetSet ()
352                 {
353                         type.Name = "Test1";
354
355                         CodeMemberProperty property = new CodeMemberProperty ();
356                         property.Name = "Name";
357                         property.Attributes = MemberAttributes.Assembly;
358                         property.HasGet = true;
359                         property.HasSet = true;
360                         property.Type = new CodeTypeReference (typeof (int));
361                         type.Members.Add (property);
362
363                         Generate ();
364                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
365                                 "public class Test1 {{{0}"
366                                 + "    {0}"
367 #if NET_2_0
368                                 + "    internal virtual int Name {{{0}"
369 #else
370                                 + "    internal int Name {{{0}"
371 #endif
372                                 + "        get {{{0}"
373                                 + "        }}{0}"
374                                 + "        set {{{0}"
375                                 + "        }}{0}"
376                                 + "    }}{0}"
377                                 + "}}{0}", writer.NewLine), Code);
378                 }
379
380                 [Test]
381                 public void PropertyMembersTypeFamilyAndAssembly ()
382                 {
383                         type.Name = "Test1";
384
385                         CodeMemberProperty property = new CodeMemberProperty ();
386                         property.Name = "Name";
387                         property.Attributes = MemberAttributes.FamilyAndAssembly;
388                         property.Type = new CodeTypeReference (typeof (int));
389
390                         type.Members.Add (property);
391
392                         Generate ();
393                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
394                                 "public class Test1 {{{0}"
395                                 + "    {0}"
396 #if NET_2_0
397                                 + "    internal int Name {{{0}"
398 #else
399                                 + "    /*FamANDAssem*/ internal int Name {{{0}"
400 #endif
401                                 + "    }}{0}"
402                                 + "}}{0}", writer.NewLine), Code);
403                 }
404
405                 /// <summary>
406                 /// C# CodeDOM does not output parameters for properties that aren't
407                 /// indexers.
408                 /// </summary>
409                 [Test]
410                 public void PropertyParametersTest ()
411                 {
412                         type.Name = "Test1";
413
414                         CodeMemberProperty property = new CodeMemberProperty ();
415                         property.Name = "Name";
416                         property.Attributes = MemberAttributes.Public;
417                         property.Type = new CodeTypeReference (typeof (int));
418
419                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
420                                 typeof (object), "value1");
421                         property.Parameters.Add (param);
422
423                         param = new CodeParameterDeclarationExpression (
424                                 typeof (int), "value2");
425                         param.Direction = FieldDirection.Ref;
426                         property.Parameters.Add (param);
427
428                         type.Members.Add (property);
429
430                         Generate ();
431                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
432                                 "public class Test1 {{{0}"
433                                 + "    {0}"
434                                 + "    public virtual int Name {{{0}"
435                                 + "    }}{0}"
436                                 + "}}{0}", writer.NewLine), Code);
437                 }
438
439                 [Test]
440                 public void PropertyIndexerTest1 ()
441                 {
442                         type.Name = "Test1";
443
444                         CodeMemberProperty property = new CodeMemberProperty ();
445                         // ensure case-insensitive comparison is done on name of property
446                         property.Name = "iTem";
447                         property.Attributes = MemberAttributes.Public;
448                         property.Type = new CodeTypeReference (typeof (int));
449
450                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
451                                 typeof (object), "value1");
452                         property.Parameters.Add (param);
453
454                         param = new CodeParameterDeclarationExpression (
455                                 typeof (int), "value2");
456                         param.Direction = FieldDirection.Ref;
457                         property.Parameters.Add (param);
458
459                         type.Members.Add (property);
460
461                         Generate ();
462                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
463                                 "public class Test1 {{{0}"
464                                 + "    {0}"
465                                 + "    public virtual int this[object value1, ref int value2] {{{0}"
466                                 + "    }}{0}"
467                                 + "}}{0}", writer.NewLine), Code);
468                 }
469
470                 /// <summary>
471                 /// Ensures indexer code is only output if property is named "Item"
472                 /// (case-insensitive comparison) AND parameters are defined.
473                 /// </summary>
474                 [Test]
475                 public void PropertyIndexerTest2 ()
476                 {
477                         type.Name = "Test1";
478
479                         CodeMemberProperty property = new CodeMemberProperty ();
480                         // ensure case-insensitive comparison is done on name of property
481                         property.Name = "iTem";
482                         property.Attributes = MemberAttributes.Public;
483                         property.Type = new CodeTypeReference (typeof (int));
484                         type.Members.Add (property);
485
486                         Generate ();
487                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
488                                 "public class Test1 {{{0}"
489                                 + "    {0}"
490                                 + "    public virtual int iTem {{{0}"
491                                 + "    }}{0}"
492                                 + "}}{0}", writer.NewLine), Code);
493                 }
494
495                 [Test]
496                 public void PropertyIndexerGetOnly ()
497                 {
498                         type.Name = "Test1";
499
500                         CodeMemberProperty property = new CodeMemberProperty ();
501                         // ensure case-insensitive comparison is done on name of property
502                         property.Name = "iTem";
503                         property.Attributes = MemberAttributes.Family;
504                         property.HasGet = true;
505                         property.Type = new CodeTypeReference (typeof (int));
506
507                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
508                                 typeof (object), "value1");
509                         property.Parameters.Add (param);
510
511                         type.Members.Add (property);
512
513                         Generate ();
514                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
515                                 "public class Test1 {{{0}"
516                                 + "    {0}"
517                                 + "    protected virtual int this[object value1] {{{0}"
518                                 + "        get {{{0}"
519                                 + "        }}{0}"
520                                 + "    }}{0}"
521                                 + "}}{0}", writer.NewLine), Code);
522                 }
523
524                 [Test]
525                 public void PropertyIndexerSetOnly ()
526                 {
527                         type.Name = "Test1";
528
529                         CodeMemberProperty property = new CodeMemberProperty ();
530                         // ensure case-insensitive comparison is done on name of property
531                         property.Name = "iTem";
532                         property.Attributes = MemberAttributes.Family;
533                         property.HasSet = true;
534                         property.Type = new CodeTypeReference (typeof (int));
535
536                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
537                                 typeof (object), "value1");
538                         property.Parameters.Add (param);
539
540                         type.Members.Add (property);
541
542                         Generate ();
543                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
544                                 "public class Test1 {{{0}"
545                                 + "    {0}"
546                                 + "    protected virtual int this[object value1] {{{0}"
547                                 + "        set {{{0}"
548                                 + "        }}{0}"
549                                 + "    }}{0}"
550                                 + "}}{0}", writer.NewLine), Code);
551                 }
552
553                 [Test]
554                 public void PropertyImplementationTypes ()
555                 {
556                         type.Name = "Test1";
557
558                         CodeMemberProperty property = new CodeMemberProperty ();
559                         property.Name = "Name";
560                         property.Attributes = MemberAttributes.Public;
561                         property.Type = new CodeTypeReference (typeof (int));
562                         property.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
563                         property.ImplementationTypes.Add (new CodeTypeReference ("IWhatever"));
564                         type.Members.Add (property);
565
566                         Generate ();
567                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
568                                 "public class Test1 {{{0}"
569                                 + "    {0}"
570                                 + "    public virtual int Name {{{0}"
571                                 + "    }}{0}"
572                                 + "}}{0}", writer.NewLine), Code);
573                 }
574
575                 [Test]
576                 public void PropertyOverloadsTest1 ()
577                 {
578                         type.Name = "Test1";
579
580                         CodeMemberProperty property = new CodeMemberProperty ();
581                         property.Name = "Name";
582                         property.Attributes = MemberAttributes.Public | MemberAttributes.Overloaded;
583                         property.Type = new CodeTypeReference (typeof (int));
584                         type.Members.Add (property);
585
586                         Generate ();
587                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
588                                 "public class Test1 {{{0}"
589                                 + "    {0}"
590                                 + "    public virtual int Name {{{0}"
591                                 + "    }}{0}"
592                                 + "}}{0}", writer.NewLine), Code);
593                 }
594
595                 [Test]
596                 public void PropertyOverloadsTest2 ()
597                 {
598                         type.Name = "Test1";
599
600                         CodeMemberProperty property = new CodeMemberProperty ();
601                         property.Name = "Name";
602                         property.Attributes = MemberAttributes.Public;
603                         property.Type = new CodeTypeReference (typeof (int));
604                         type.Members.Add (property);
605
606                         property = new CodeMemberProperty ();
607                         property.Name = "Name";
608                         property.Attributes = MemberAttributes.Private;
609                         property.Type = new CodeTypeReference (typeof (int));
610                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
611                                 typeof (object), "value1");
612                         property.Parameters.Add (param);
613                         type.Members.Add (property);
614
615                         Generate ();
616                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
617                                 "public class Test1 {{{0}"
618                                 + "    {0}"
619                                 + "    public virtual int Name {{{0}"
620                                 + "    }}{0}"
621                                 + "    {0}"
622                                 + "    private int Name {{{0}"
623                                 + "    }}{0}"
624                                 + "}}{0}", writer.NewLine), Code);
625                 }
626
627                 [Test]
628                 public void PropertyOverloadsTest3 ()
629                 {
630                         type.Name = "Test1";
631
632                         CodeMemberProperty property = new CodeMemberProperty ();
633                         property.Name = "Name";
634                         property.Attributes = MemberAttributes.Public;
635                         property.Type = new CodeTypeReference (typeof (int));
636                         type.Members.Add (property);
637
638                         property = new CodeMemberProperty ();
639                         property.Name = "Name";
640                         property.Attributes = MemberAttributes.Private;
641                         property.Type = new CodeTypeReference (typeof (int));
642                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
643                                 typeof (object), "value1");
644                         property.Parameters.Add (param);
645                         property.PrivateImplementationType = new CodeTypeReference (typeof (int));
646                         type.Members.Add (property);
647
648                         Generate ();
649                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
650                                 "public class Test1 {{{0}"
651                                 + "    {0}"
652                                 + "    public virtual int Name {{{0}"
653                                 + "    }}{0}"
654                                 + "    {0}"
655                                 + "    int System.Int32.Name {{{0}"
656                                 + "    }}{0}"
657                                 + "}}{0}", writer.NewLine), Code);
658                 }
659
660                 /// <summary>
661                 /// Ensure no access modifiers are output if PrivateImplementationType
662                 /// is set.
663                 /// </summary>
664                 [Test]
665                 public void PropertyPrivateImplementationType ()
666                 {
667                         type.Name = "Test1";
668
669                         CodeMemberProperty property = new CodeMemberProperty ();
670                         property.Name = "Item";
671                         property.Attributes = MemberAttributes.Public | MemberAttributes.Overloaded;
672                         property.Type = new CodeTypeReference (typeof (int));
673                         property.PrivateImplementationType = new CodeTypeReference (typeof (int));
674                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
675                                 typeof (object), "value1");
676                         property.Parameters.Add (param);
677                         type.Members.Add (property);
678
679                         Generate ();
680                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
681                                 "public class Test1 {{{0}"
682                                 + "    {0}"
683                                 + "    int System.Int32.this[object value1] {{{0}"
684                                 + "    }}{0}"
685                                 + "}}{0}", writer.NewLine), Code);
686                 }
687
688                 [Test]
689                 public void PropertyImplementationTypeOrder ()
690                 {
691                         type.Name = "Test1";
692
693                         CodeMemberProperty property = new CodeMemberProperty ();
694                         property.Name = "Item";
695                         property.Attributes = MemberAttributes.Public | MemberAttributes.Overloaded;
696                         property.Type = new CodeTypeReference (typeof (int));
697                         property.PrivateImplementationType = new CodeTypeReference (typeof (int));
698                         property.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
699                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
700                                 typeof (object), "value1");
701                         property.Parameters.Add (param);
702                         type.Members.Add (property);
703
704                         Generate ();
705                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
706                                 "public class Test1 {{{0}"
707                                 + "    {0}"
708                                 + "    int System.Int32.this[object value1] {{{0}"
709                                 + "    }}{0}"
710                                 + "}}{0}", writer.NewLine), Code);
711                 }
712
713                 [Test]
714                 public void MethodMembersTypeTest1 ()
715                 {
716                         type.Name = "Test1";
717
718                         CodeMemberMethod method = new CodeMemberMethod ();
719
720                         CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
721                         attrDec.Name = "A";
722                         method.CustomAttributes.Add (attrDec);
723
724                         attrDec = new CodeAttributeDeclaration ();
725                         attrDec.Name = "B";
726                         method.CustomAttributes.Add (attrDec);
727
728                         // C# does not support Implementation Types, so this should be ignored
729                         method.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
730
731                         type.Members.Add (method);
732
733                         Generate ();
734                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
735                                 "public class Test1 {{{0}"
736                                 + "    {0}"
737                                 + "    [A()]{0}"
738                                 + "    [B()]{0}"
739                                 + "    private void () {{{0}"
740                                 + "    }}{0}"
741                                 + "}}{0}", writer.NewLine), Code);
742                 }
743
744                 [Test]
745                 public void MethodMembersTypeTest2 ()
746                 {
747                         type.Name = "Test1";
748
749                         CodeMemberMethod method = new CodeMemberMethod ();
750                         method.Name = "Something";
751                         method.Attributes = MemberAttributes.Public;
752                         method.ReturnType = new CodeTypeReference (typeof (int));
753
754                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
755                                 typeof (object), "value1");
756                         method.Parameters.Add (param);
757
758                         param = new CodeParameterDeclarationExpression (
759                                 typeof (object), "value2");
760                         param.Direction = FieldDirection.In;
761                         method.Parameters.Add (param);
762
763                         param = new CodeParameterDeclarationExpression (typeof (int), "index");
764                         param.Direction = FieldDirection.Out;
765                         method.Parameters.Add (param);
766
767                         param = new CodeParameterDeclarationExpression (typeof (int), "count");
768                         param.Direction = FieldDirection.Ref;
769                         method.Parameters.Add (param);
770
771                         type.Members.Add (method);
772
773                         Generate ();
774                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
775                                 "public class Test1 {{{0}"
776                                 + "    {0}"
777                                 + "    public virtual int Something(object value1, object value2, out int index, ref int count) {{{0}"
778                                 + "    }}{0}"
779                                 + "}}{0}", writer.NewLine), Code);
780                 }
781
782                 [Test]
783                 public void MethodMembersTypeTest3 ()
784                 {
785                         type.Name = "Test1";
786
787                         CodeMemberMethod method = new CodeMemberMethod ();
788                         method.Name = "Something";
789                         method.Attributes = MemberAttributes.Public;
790                         method.ReturnType = new CodeTypeReference (typeof (int));
791
792                         // first parameter
793                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
794                                 typeof (object), "value");
795                         method.Parameters.Add (param);
796
797                         CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
798                         attrDec.Name = "A";
799                         param.CustomAttributes.Add (attrDec);
800
801                         attrDec = new CodeAttributeDeclaration ();
802                         attrDec.Name = "B";
803                         param.CustomAttributes.Add (attrDec);
804
805                         // second parameter
806                         param = new CodeParameterDeclarationExpression (typeof (int), "index");
807                         param.Direction = FieldDirection.Out;
808                         method.Parameters.Add (param);
809
810                         attrDec = new CodeAttributeDeclaration ();
811                         attrDec.Name = "C";
812                         attrDec.Arguments.Add (new CodeAttributeArgument ("A1",
813                                 new CodePrimitiveExpression (false)));
814                         attrDec.Arguments.Add (new CodeAttributeArgument ("A2",
815                                 new CodePrimitiveExpression (true)));
816                         param.CustomAttributes.Add (attrDec);
817
818                         attrDec = new CodeAttributeDeclaration ();
819                         attrDec.Name = "D";
820                         param.CustomAttributes.Add (attrDec);
821
822                         type.Members.Add (method);
823
824                         Generate ();
825                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
826                                 "public class Test1 {{{0}"
827                                 + "    {0}"
828                                 + "    public virtual int Something([A()] [B()] object value, [C(A1=false, A2=true)] [D()] out int index) {{{0}"
829                                 + "    }}{0}"
830                                 + "}}{0}", writer.NewLine), Code);
831                 }
832
833                 [Test]
834                 public void MethodImplementationTypes ()
835                 {
836                         type.Name = "Test1";
837
838                         CodeMemberMethod method = new CodeMemberMethod ();
839                         method.Name = "Execute";
840                         method.Attributes = MemberAttributes.Assembly;
841                         method.ReturnType = new CodeTypeReference (typeof (int));
842                         method.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
843                         method.ImplementationTypes.Add (new CodeTypeReference ("IWhatever"));
844                         type.Members.Add (method);
845
846                         Generate ();
847                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
848                                 "public class Test1 {{{0}"
849                                 + "    {0}"
850 #if NET_2_0
851                                 + "    internal virtual int Execute() {{{0}"
852 #else
853                                 + "    internal int Execute() {{{0}"
854 #endif
855                                 + "    }}{0}"
856                                 + "}}{0}", writer.NewLine), Code);
857                 }
858
859                 [Test]
860                 public void MethodOverloadsTest1 ()
861                 {
862                         type.Name = "Test1";
863
864                         CodeMemberMethod method = new CodeMemberMethod ();
865                         method.Name = "Execute";
866                         method.Attributes = MemberAttributes.Public | MemberAttributes.Overloaded;
867                         method.ReturnType = new CodeTypeReference (typeof (int));
868                         type.Members.Add (method);
869
870                         Generate ();
871                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
872                                 "public class Test1 {{{0}"
873                                 + "    {0}"
874                                 + "    public virtual int Execute() {{{0}"
875                                 + "    }}{0}"
876                                 + "}}{0}", writer.NewLine), Code);
877                 }
878
879                 [Test]
880                 public void MethodOverloadsTest2 ()
881                 {
882                         type.Name = "Test1";
883
884                         CodeMemberMethod method = new CodeMemberMethod ();
885                         method.Name = "Execute";
886                         method.Attributes = MemberAttributes.Public;
887                         type.Members.Add (method);
888
889                         method = new CodeMemberMethod ();
890                         method.Name = "Execute";
891                         method.Attributes = MemberAttributes.Private;
892                         method.ReturnType = new CodeTypeReference (typeof (int));
893                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
894                                 typeof (object), "value1");
895                         method.Parameters.Add (param);
896                         type.Members.Add (method);
897
898                         Generate ();
899                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
900                                 "public class Test1 {{{0}"
901                                 + "    {0}"
902                                 + "    public virtual void Execute() {{{0}"
903                                 + "    }}{0}"
904                                 + "    {0}"
905                                 + "    private int Execute(object value1) {{{0}"
906                                 + "    }}{0}"
907                                 + "}}{0}", writer.NewLine), Code);
908                 }
909
910                 [Test]
911                 public void MethodOverloadsTest3 ()
912                 {
913                         type.Name = "Test1";
914
915                         CodeMemberMethod method = new CodeMemberMethod ();
916                         method.Name = "Execute";
917                         method.Attributes = MemberAttributes.Public;
918                         type.Members.Add (method);
919
920                         method = new CodeMemberMethod ();
921                         method.Name = "Execute";
922                         method.Attributes = MemberAttributes.Private;
923                         method.ReturnType = new CodeTypeReference (typeof (int));
924                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
925                                 typeof (object), "value1");
926                         method.Parameters.Add (param);
927                         method.PrivateImplementationType = new CodeTypeReference (typeof (int));
928                         type.Members.Add (method);
929
930                         Generate ();
931                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
932                                 "public class Test1 {{{0}"
933                                 + "    {0}"
934                                 + "    public virtual void Execute() {{{0}"
935                                 + "    }}{0}"
936                                 + "    {0}"
937                                 + "    int System.Int32.Execute(object value1) {{{0}"
938                                 + "    }}{0}"
939                                 + "}}{0}", writer.NewLine), Code);
940                 }
941
942                 /// <summary>
943                 /// Ensure no access modifiers are output if PrivateImplementationType
944                 /// is set.
945                 /// </summary>
946                 [Test]
947                 public void MethodPrivateImplementationType ()
948                 {
949                         type.Name = "Test1";
950
951                         CodeMemberMethod method = new CodeMemberMethod ();
952                         method.Name = "Execute";
953                         method.Attributes = MemberAttributes.Public | MemberAttributes.Overloaded;
954                         method.ReturnType = new CodeTypeReference (typeof (int));
955                         method.PrivateImplementationType = new CodeTypeReference (typeof (int));
956                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
957                                 typeof (object), "value1");
958                         method.Parameters.Add (param);
959                         type.Members.Add (method);
960
961                         Generate ();
962                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
963                                 "public class Test1 {{{0}"
964                                 + "    {0}"
965                                 + "    int System.Int32.Execute(object value1) {{{0}"
966                                 + "    }}{0}"
967                                 + "}}{0}", writer.NewLine), Code);
968                 }
969
970                 [Test]
971                 public void MethodImplementationTypeOrder ()
972                 {
973                         type.Name = "Test1";
974
975                         CodeMemberMethod method = new CodeMemberMethod ();
976                         method.Name = "Execute";
977                         method.Attributes = MemberAttributes.Public;
978                         method.ReturnType = new CodeTypeReference (typeof (int));
979                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
980                                 typeof (object), "value1");
981                         method.Parameters.Add (param);
982                         method.PrivateImplementationType = new CodeTypeReference (typeof (int));
983                         method.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
984                         type.Members.Add (method);
985
986                         Generate ();
987                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
988                                 "public class Test1 {{{0}"
989                                 + "    {0}"
990                                 + "    int System.Int32.Execute(object value1) {{{0}"
991                                 + "    }}{0}"
992                                 + "}}{0}", writer.NewLine), Code);
993                 }
994
995                 [Test]
996                 public void MethodReturnTypeAttributes ()
997                 {
998                         type.Name = "Test1";
999
1000                         CodeMemberMethod method = new CodeMemberMethod ();
1001                         method.Name = "Execute";
1002                         method.Attributes = MemberAttributes.Public;
1003                         method.ReturnType = new CodeTypeReference (typeof (int));
1004                         type.Members.Add (method);
1005
1006                         // method custom attributes
1007                         CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
1008                         attrDec.Name = "A";
1009                         method.CustomAttributes.Add (attrDec);
1010
1011                         attrDec = new CodeAttributeDeclaration ();
1012                         attrDec.Name = "B";
1013                         method.CustomAttributes.Add (attrDec);
1014
1015                         // return type custom attributes
1016                         attrDec = new CodeAttributeDeclaration ();
1017                         attrDec.Name = "C";
1018                         attrDec.Arguments.Add (new CodeAttributeArgument ("A1",
1019                                 new CodePrimitiveExpression (false)));
1020                         attrDec.Arguments.Add (new CodeAttributeArgument ("A2",
1021                                 new CodePrimitiveExpression (true)));
1022                         method.ReturnTypeCustomAttributes.Add (attrDec);
1023
1024                         attrDec = new CodeAttributeDeclaration ();
1025                         attrDec.Name = "D";
1026                         method.ReturnTypeCustomAttributes.Add (attrDec);
1027
1028                         Generate ();
1029                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1030                                 "public class Test1 {{{0}"
1031                                 + "    {0}"
1032                                 + "    [A()]{0}"
1033                                 + "    [B()]{0}"
1034                                 + "    [return: C(A1=false, A2=true)]{0}"
1035                                 + "    [return: D()]{0}"
1036                                 + "    public virtual int Execute() {{{0}"
1037                                 + "    }}{0}"
1038                                 + "}}{0}", writer.NewLine), Code);
1039                 }
1040
1041                 [Test]
1042                 public void ConstructorAttributesTest ()
1043                 {
1044                         type.Name = "Test1";
1045
1046                         CodeConstructor ctor = new CodeConstructor ();
1047
1048                         CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
1049                         attrDec.Name = "A";
1050                         ctor.CustomAttributes.Add (attrDec);
1051
1052                         attrDec = new CodeAttributeDeclaration ();
1053                         attrDec.Name = "B";
1054                         ctor.CustomAttributes.Add (attrDec);
1055
1056                         // C# does not support Implementation Types, so this should be ignored
1057                         ctor.ImplementationTypes.Add (new CodeTypeReference ("IPolicy"));
1058
1059                         type.Members.Add (ctor);
1060
1061                         Generate ();
1062                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1063                                 "public class Test1 {{{0}"
1064                                 + "    {0}"
1065                                 + "    [A()]{0}"
1066                                 + "    [B()]{0}"
1067                                 + "    private Test1() {{{0}"
1068                                 + "    }}{0}"
1069                                 + "}}{0}", writer.NewLine), Code);
1070                 }
1071
1072                 [Test]
1073                 public void ConstructorParametersTest ()
1074                 {
1075                         type.Name = "Test1";
1076
1077                         CodeConstructor ctor = new CodeConstructor ();
1078                         ctor.Name = "Whatever";
1079                         ctor.Attributes = MemberAttributes.Public;
1080
1081                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
1082                                 typeof (object), "value1");
1083                         ctor.Parameters.Add (param);
1084
1085                         param = new CodeParameterDeclarationExpression (
1086                                 typeof (object), "value2");
1087                         param.Direction = FieldDirection.In;
1088                         ctor.Parameters.Add (param);
1089
1090                         param = new CodeParameterDeclarationExpression (typeof (int), "index");
1091                         param.Direction = FieldDirection.Out;
1092                         ctor.Parameters.Add (param);
1093
1094                         param = new CodeParameterDeclarationExpression (typeof (int), "count");
1095                         param.Direction = FieldDirection.Ref;
1096                         ctor.Parameters.Add (param);
1097
1098                         type.Members.Add (ctor);
1099
1100                         Generate ();
1101                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1102                                 "public class Test1 {{{0}"
1103                                 + "    {0}"
1104                                 + "    public Test1(object value1, object value2, out int index, ref int count) {{{0}"
1105                                 + "    }}{0}"
1106                                 + "}}{0}", writer.NewLine), Code);
1107                 }
1108
1109                 [Test]
1110                 public void ConstructorParameterAttributesTest ()
1111                 {
1112                         type.Name = "Test1";
1113
1114                         CodeConstructor ctor = new CodeConstructor ();
1115                         ctor.Name = "Something";
1116                         ctor.Attributes = MemberAttributes.Public;
1117
1118                         // first parameter
1119                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
1120                                 typeof (object), "value");
1121                         ctor.Parameters.Add (param);
1122
1123                         CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
1124                         attrDec.Name = "A";
1125                         param.CustomAttributes.Add (attrDec);
1126
1127                         attrDec = new CodeAttributeDeclaration ();
1128                         attrDec.Name = "B";
1129                         param.CustomAttributes.Add (attrDec);
1130
1131                         // second parameter
1132                         param = new CodeParameterDeclarationExpression (typeof (int), "index");
1133                         param.Direction = FieldDirection.Out;
1134                         ctor.Parameters.Add (param);
1135
1136                         attrDec = new CodeAttributeDeclaration ();
1137                         attrDec.Name = "C";
1138                         attrDec.Arguments.Add (new CodeAttributeArgument ("A1",
1139                                 new CodePrimitiveExpression (false)));
1140                         attrDec.Arguments.Add (new CodeAttributeArgument ("A2",
1141                                 new CodePrimitiveExpression (true)));
1142                         param.CustomAttributes.Add (attrDec);
1143
1144                         attrDec = new CodeAttributeDeclaration ();
1145                         attrDec.Name = "D";
1146                         param.CustomAttributes.Add (attrDec);
1147
1148                         type.Members.Add (ctor);
1149
1150                         Generate ();
1151                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1152                                 "public class Test1 {{{0}"
1153                                 + "    {0}"
1154                                 + "    public Test1([A()] [B()] object value, [C(A1=false, A2=true)] [D()] out int index) {{{0}"
1155                                 + "    }}{0}"
1156                                 + "}}{0}", writer.NewLine), Code);
1157                 }
1158
1159                 [Test]
1160                 public void BaseConstructorSingleArg ()
1161                 {
1162                         type.Name = "Test1";
1163
1164                         CodeConstructor ctor = new CodeConstructor ();
1165                         ctor.Name = "Something";
1166                         ctor.Attributes = MemberAttributes.Public;
1167
1168                         // first parameter
1169                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
1170                                 typeof (object), "value1");
1171                         ctor.Parameters.Add (param);
1172
1173                         // second parameter
1174                         param = new CodeParameterDeclarationExpression (typeof (int), "value2");
1175                         param.Direction = FieldDirection.Out;
1176                         ctor.Parameters.Add (param);
1177
1178                         // base ctor args
1179                         ctor.BaseConstructorArgs.Add (new CodeVariableReferenceExpression ("value1"));
1180
1181                         type.Members.Add (ctor);
1182
1183                         Generate ();
1184                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1185                                 "public class Test1 {{{0}"
1186                                 + "    {0}"
1187                                 + "    public Test1(object value1, out int value2) : {0}"
1188                                 + "            base(value1) {{{0}"
1189                                 + "    }}{0}"
1190                                 + "}}{0}", writer.NewLine), Code);
1191                 }
1192
1193                 [Test]
1194                 public void BaseConstructorMultipleArgs ()
1195                 {
1196                         type.Name = "Test1";
1197
1198                         CodeConstructor ctor = new CodeConstructor ();
1199                         ctor.Name = "Something";
1200                         ctor.Attributes = MemberAttributes.Public;
1201
1202                         // first parameter
1203                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
1204                                 typeof (object), "value1");
1205                         ctor.Parameters.Add (param);
1206
1207                         // second parameter
1208                         param = new CodeParameterDeclarationExpression (typeof (int), "value2");
1209                         param.Direction = FieldDirection.Out;
1210                         ctor.Parameters.Add (param);
1211
1212                         // base ctor args
1213                         ctor.BaseConstructorArgs.Add (new CodeVariableReferenceExpression ("value1"));
1214                         ctor.BaseConstructorArgs.Add (new CodeVariableReferenceExpression ("value2"));
1215
1216                         type.Members.Add (ctor);
1217
1218                         Generate ();
1219                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1220                                 "public class Test1 {{{0}"
1221                                 + "    {0}"
1222                                 + "    public Test1(object value1, out int value2) : {0}"
1223                                 + "            base(value1, value2) {{{0}"
1224                                 + "    }}{0}"
1225                                 + "}}{0}", writer.NewLine), Code);
1226                 }
1227
1228                 [Test]
1229                 public void ChainedConstructorSingleArg ()
1230                 {
1231                         type.Name = "Test1";
1232
1233                         CodeConstructor ctor = new CodeConstructor ();
1234                         ctor.Name = "Something";
1235                         ctor.Attributes = MemberAttributes.Public;
1236
1237                         // first parameter
1238                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
1239                                 typeof (object), "value1");
1240                         ctor.Parameters.Add (param);
1241
1242                         // second parameter
1243                         param = new CodeParameterDeclarationExpression (typeof (int), "value2");
1244                         param.Direction = FieldDirection.Out;
1245                         ctor.Parameters.Add (param);
1246
1247                         // chained ctor args
1248                         ctor.ChainedConstructorArgs.Add (new CodeVariableReferenceExpression ("value1"));
1249
1250                         type.Members.Add (ctor);
1251
1252                         Generate ();
1253                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1254                                 "public class Test1 {{{0}"
1255                                 + "    {0}"
1256                                 + "    public Test1(object value1, out int value2) : {0}"
1257                                 + "            this(value1) {{{0}"
1258                                 + "    }}{0}"
1259                                 + "}}{0}", writer.NewLine), Code);
1260                 }
1261
1262                 [Test]
1263                 public void ChainedConstructorMultipleArgs ()
1264                 {
1265                         type.Name = "Test1";
1266
1267                         CodeConstructor ctor = new CodeConstructor ();
1268                         ctor.Name = "Something";
1269                         ctor.Attributes = MemberAttributes.Public;
1270
1271                         // first parameter
1272                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
1273                                 typeof (object), "value1");
1274                         ctor.Parameters.Add (param);
1275
1276                         // second parameter
1277                         param = new CodeParameterDeclarationExpression (typeof (int), "value2");
1278                         param.Direction = FieldDirection.Out;
1279                         ctor.Parameters.Add (param);
1280
1281                         // chained ctor args
1282                         ctor.ChainedConstructorArgs.Add (new CodeVariableReferenceExpression ("value1"));
1283                         ctor.ChainedConstructorArgs.Add (new CodeVariableReferenceExpression ("value2"));
1284
1285                         type.Members.Add (ctor);
1286
1287                         Generate ();
1288                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1289                                 "public class Test1 {{{0}"
1290                                 + "    {0}"
1291                                 + "    public Test1(object value1, out int value2) : {0}"
1292                                 + "            this(value1, value2) {{{0}"
1293                                 + "    }}{0}"
1294                                 + "}}{0}", writer.NewLine), Code);
1295                 }
1296
1297                 [Test]
1298                 public void BaseAndChainedConstructorArg ()
1299                 {
1300                         type.Name = "Test1";
1301
1302                         CodeConstructor ctor = new CodeConstructor ();
1303                         ctor.Name = "Something";
1304                         ctor.Attributes = MemberAttributes.Public;
1305
1306                         // first parameter
1307                         CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (
1308                                 typeof (object), "value1");
1309                         ctor.Parameters.Add (param);
1310
1311                         // second parameter
1312                         param = new CodeParameterDeclarationExpression (typeof (int), "value2");
1313                         param.Direction = FieldDirection.Out;
1314                         ctor.Parameters.Add (param);
1315
1316                         // base ctor args
1317                         ctor.BaseConstructorArgs.Add (new CodeVariableReferenceExpression ("value1"));
1318
1319                         // chained ctor args
1320                         ctor.ChainedConstructorArgs.Add (new CodeVariableReferenceExpression ("value1"));
1321                         ctor.ChainedConstructorArgs.Add (new CodeVariableReferenceExpression ("value2"));
1322
1323                         type.Members.Add (ctor);
1324
1325                         Generate ();
1326                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1327                                 "public class Test1 {{{0}"
1328                                 + "    {0}"
1329                                 + "    public Test1(object value1, out int value2) : {0}"
1330                                 + "            base(value1) : {0}"
1331                                 + "            this(value1, value2) {{{0}"
1332                                 + "    }}{0}"
1333                                 + "}}{0}", writer.NewLine), Code);
1334                 }
1335
1336                 /*
1337                 [Test]
1338                 public void ReferencedTest ()
1339                 {
1340                         codeUnit.ReferencedAssemblies.Add ("System.dll");
1341                         Generate ();
1342                         Assertion.AssertEquals ("", Code);
1343                 }
1344                 */
1345         }
1346 }