2 // Microsoft.VisualBasic.* Test Cases
5 // Gert Driesen (drieseng@users.sourceforge.net)
12 using System.CodeDom.Compiler;
13 using System.Globalization;
15 using Microsoft.VisualBasic;
17 using NUnit.Framework;
19 using MonoTests.System.CodeDom.Compiler;
21 namespace MonoTests.Microsoft.VisualBasic
24 public class CodeGeneratorFromTypeTest_Class : CodeGeneratorFromTypeTestBase
26 private CodeTypeDeclaration _typeDeclaration;
27 private ICodeGenerator _codeGenerator;
29 protected override ICodeGenerator CodeGenerator
31 get { return _codeGenerator; }
34 protected override CodeTypeDeclaration TypeDeclaration
36 get { return _typeDeclaration; }
40 public override void SetUp ()
43 _typeDeclaration = new CodeTypeDeclaration ();
45 CodeDomProvider provider = new VBCodeProvider ();
46 _codeGenerator = provider.CreateGenerator ();
50 public override void DefaultTypeTest ()
52 string code = GenerateDefaultType (Options);
53 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
55 "End Class{0}", NewLine), code);
59 [ExpectedException (typeof (NullReferenceException))]
60 public override void NullTypeTest ()
62 GenerateNullType (Options);
66 public override void SimpleTypeTest ()
68 string code = GenerateSimpleType (Options);
69 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
70 "Public Class Test1{0}" +
71 "End Class{0}", NewLine), code);
75 public override void DerivedTypeTest ()
77 string code = GenerateDerivedType (Options);
78 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
80 "Friend MustInherit Class Test1{0}" +
82 "MustInherit Class Test1{0}" +
84 " Inherits Integer{0}" +
85 " Implements System.Security.Principal.IIdentity, String, System.Security.IPermission{0}" +
86 "End Class{0}", NewLine), code);
90 public override void AttributesAndTypeTest ()
92 string code = GenerateAttributesAndType (Options);
93 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
96 "Public Class Test1{0}" +
97 "End Class{0}", NewLine), code);
101 public override void EventMembersTypeTest1 ()
103 string code = GenerateEventMembersType1 (Options);
104 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
105 "Public Class Test1{0}" +
110 " Private Event __exception As System.Void{0}" +
112 " Private Event As System.Void{0}" +
114 "End Class{0}", NewLine), code);
118 public override void EventMembersTypeTest2 ()
120 string code = GenerateEventMembersType2 (Options);
121 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
122 "Public Class Test1{0}" +
124 " Public Event Click As Integer{0}" +
125 "End Class{0}", NewLine), code);
129 public override void EventImplementationTypes ()
131 string code = GenerateEventImplementationTypes (Options);
132 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
133 "Public Class Test1{0}" +
136 " Friend Event Click As Integer Implements IPolicy.Click , IWhatever.Click{0}" +
138 " Friend Event Click As Integer{0}" +
140 "End Class{0}", NewLine), code);
144 /// Ensure no access modifiers are output if PrivateImplementationType
148 public override void EventPrivateImplementationType ()
150 string code = GenerateEventPrivateImplementationType (Options);
151 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
152 "Public Class Test1{0}" +
155 " Protected Event System_Int32_Click As Integer Implements Integer.Click{0}" +
157 " Protected Event Click As Integer{0}" +
159 "End Class{0}", NewLine), code);
163 /// If both ImplementationTypes and PrivateImplementationType are set,
164 /// then only ImplementationTypes are output.
167 public override void EventImplementationTypeOrder ()
169 string code = GenerateEventImplementationTypeOrder (Options);
170 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
171 "Public Class Test1{0}" +
174 " Public Event System_Int32_Click As Integer Implements IPolicy.Click{0}" +
176 " Public Event Click As Integer{0}" +
178 "End Class{0}", NewLine), code);
182 public override void FieldMembersAttributesTest ()
184 string code = GenerateFieldMembersAttributes (Options);
185 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
186 "Public Class Test1{0}" +
191 " Private __exception As System.Void{0}" +
193 " Private As System.Void{0}" +
195 "End Class{0}", NewLine), code);
199 public override void FieldMembersTypeTest ()
201 string code = GenerateFieldMembersType (MemberAttributes.Public, Options);
202 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
203 "Public Class Test1{0}" +
205 " Public Name As Integer = 2{0}" +
206 "End Class{0}", NewLine), code);
210 public override void FieldNewSlotTest ()
212 string code = GenerateFieldMembersType (MemberAttributes.Assembly |
213 MemberAttributes.New, Options);
214 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
215 "Public Class Test1{0}" +
217 " Friend Shadows Name As Integer = 2{0}" +
218 "End Class{0}", NewLine), code);
222 public override void PropertyMembersTypeTest1 ()
224 string code = GeneratePropertyMembersAttributes (Options);
225 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
226 "Public Class Test1{0}" +
231 " Private Property () As System.Void{0}" +
233 " Private Property As System.Void{0}" +
236 "End Class{0}", NewLine), code);
240 public override void PropertyMembersTypeTest2 ()
242 string code = GeneratePropertyMembersType (MemberAttributes.Public,
243 false, false, Options);
244 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
245 "Public Class Test1{0}" +
248 " Public Overridable Property Name() As Integer{0}" +
250 " Public Overridable Property Name As Integer{0}" +
253 "End Class{0}", NewLine), code);
257 public override void PropertyMembersTypeGetOnly ()
259 string code = GeneratePropertyMembersType (MemberAttributes.Family,
260 true, false, Options);
261 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
262 "Public Class Test1{0}" +
265 " Protected Overridable ReadOnly Property Name() As Integer{0}" +
267 " Protected Overridable ReadOnly Property Name As Integer{0}" +
272 "End Class{0}", NewLine), code);
276 public override void PropertyMembersTypeSetOnly ()
278 string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
279 false, true, Options);
280 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
281 "Public Class Test1{0}" +
284 " Friend Overridable WriteOnly Property Name() As Integer{0}" +
286 " Friend WriteOnly Property Name As Integer{0}" +
291 "End Class{0}", NewLine), code);
295 public override void PropertyMembersTypeGetSet ()
297 string code = GeneratePropertyMembersType (MemberAttributes.Family,
298 true, true, Options);
299 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
300 "Public Class Test1{0}" +
303 " Protected Overridable Property Name() As Integer{0}" +
305 " Protected Overridable Property Name As Integer{0}" +
312 "End Class{0}", NewLine), code);
316 // A bug in MS.NET 1.x causes MemberAttributes.FamilyOrAssembly to be
317 // generated as Protected
318 [Category ("NotDotNet")]
321 public override void PropertyMembersTypeFamilyOrAssembly ()
323 string code = GeneratePropertyMembersType (MemberAttributes.FamilyOrAssembly,
324 false, false, Options);
325 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
326 "Public Class Test1{0}" +
329 " Protected Friend Property Name() As Integer{0}" +
331 " Protected Friend Property Name As Integer{0}" +
334 "End Class{0}", NewLine), code);
338 // A bug in MS.NET 1.x causes MemberAttributes.Assembly to be generated
340 [Category ("NotDotNet")]
343 public override void PropertyMembersTypeAssembly ()
345 string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
346 false, false, Options);
347 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
348 "Public Class Test1{0}" +
351 " Friend Overridable Property Name() As Integer{0}" +
353 " Friend Property Name As Integer{0}" +
356 "End Class{0}", NewLine), code);
360 /// Apparently VB.NET CodeDOM also allows properties that aren't indexers
361 /// to have parameters.
364 public override void PropertyParametersTest ()
366 string code = GeneratePropertyParameters (Options);
367 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
368 "Public Class Test1{0}" +
370 " Public Overridable Property Name(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
372 "End Class{0}", NewLine), code);
376 public override void PropertyIndexerTest1 ()
378 string code = GeneratePropertyIndexer (MemberAttributes.Public,
379 false, false, true, Options);
380 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
381 "Public Class Test1{0}" +
383 " Public Overridable Default Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
385 "End Class{0}", NewLine), code);
389 /// Ensures Default keyword is only output if property is named "Item"
390 /// (case-insensitive comparison) AND parameters are defined.
393 public override void PropertyIndexerTest2 ()
395 string code = GeneratePropertyIndexer (MemberAttributes.Public,
396 false, false, false, Options);
397 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
398 "Public Class Test1{0}" +
401 " Public Overridable Property iTem() As Integer{0}" +
403 " Public Overridable Property iTem As Integer{0}" +
406 "End Class{0}", NewLine), code);
410 /// Ensures Default keyword is output after ReadOnly modifier.
413 public override void PropertyIndexerGetOnly ()
415 string code = GeneratePropertyIndexer (MemberAttributes.Family,
416 true, false, true, Options);
417 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
418 "Public Class Test1{0}" +
420 " Protected Overridable Default ReadOnly Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
424 "End Class{0}", NewLine), code);
428 /// Ensures Default keyword is output after WriteOnly modifier.
431 public override void PropertyIndexerSetOnly ()
433 string code = GeneratePropertyIndexer (MemberAttributes.Family,
434 false, true, true, Options);
435 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
436 "Public Class Test1{0}" +
438 " Protected Overridable Default WriteOnly Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
442 "End Class{0}", NewLine), code);
446 public override void PropertyImplementationTypes ()
448 string code = GeneratePropertyImplementationTypes (Options);
449 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
450 "Public Class Test1{0}" +
453 " Public Overridable Property Name() As Integer Implements IPolicy.Name , IWhatever.Name{0}" +
455 " Public Overridable Property Name As Integer Implements IPolicy.Name , IWhatever.Name{0}" +
458 "End Class{0}", NewLine), code);
462 /// Ensure that Overloads keyword is output for a property which has
463 /// explicitly been marked as Overloaded.
466 public override void PropertyOverloadsTest1 ()
468 string code = GeneratePropertyOverloads1 (Options);
469 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
470 "Public Class Test1{0}" +
473 " Protected Overloads Overridable Property Name() As Integer{0}" +
475 " Protected Overloads Overridable Property Name As Integer{0}" +
478 "End Class{0}", NewLine), code);
482 /// Ensure that Overloads keyword is output if multiple properties with
483 /// the same name are defined.
486 public override void PropertyOverloadsTest2 ()
488 string code = GeneratePropertyOverloads2 (Options);
489 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
490 "Public Class Test1{0}" +
493 " Public Overloads Overridable Property Name() As Integer{0}" +
495 " Public Overloads Overridable Property Name As Integer{0}" +
499 " Private Overloads Property Name(ByVal value1 As Object) As Integer{0}" +
501 "End Class{0}", NewLine), code);
505 /// Ensure that a property with a PrivateImplementationType and with
506 /// the same name does not qualify as an overload.
509 public override void PropertyOverloadsTest3 ()
511 string code = GeneratePropertyOverloads3 (Options);
512 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
513 "Public Class Test1{0}" +
516 " Public Overridable Property Name() As Integer{0}" +
518 " Public Overridable Property Name As Integer{0}" +
522 " Property System_Int32_Name(ByVal value1 As Object) As Integer Implements Integer.Name{0}" +
524 "End Class{0}", NewLine), code);
528 /// Ensure no access modifiers are output if PrivateImplementationType
529 /// is set. Default keyword is also not output in this case.
532 public override void PropertyPrivateImplementationType ()
534 string code = GeneratePropertyPrivateImplementationType (Options);
535 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
536 "Public Class Test1{0}" +
538 " Overridable Property System_Int32_Item(ByVal value1 As Object) As Integer Implements Integer.Item{0}" +
540 "End Class{0}", NewLine), code);
544 /// If both ImplementationTypes and PrivateImplementationType are set,
545 /// then only ImplementationTypes are output.
548 public override void PropertyImplementationTypeOrder ()
550 string code = GeneratePropertyImplementationTypeOrder (Options);
551 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
552 "Public Class Test1{0}" +
554 " Overridable Property System_Int32_Item(ByVal value1 As Object) As Integer Implements IPolicy.Item{0}" +
556 "End Class{0}", NewLine), code);
560 public override void PropertyNewSlotTest ()
562 string code = GeneratePropertyMembersType (MemberAttributes.Private |
563 MemberAttributes.New, true, true, Options);
564 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
565 "Public Class Test1{0}" +
568 " Private Shadows Property Name() As Integer{0}" +
570 " Private Shadows Property Name As Integer{0}" +
577 "End Class{0}", NewLine), code);
581 public override void MethodMembersTypeTest1 ()
583 string code = GenerateMethodMembersType1 (Options);
584 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
585 "Public Class Test1{0}" +
589 " Private Sub (){0}" +
591 "End Class{0}", NewLine), code);
595 public override void MethodMembersTypeTest2 ()
597 string code = GenerateMethodMembersType2 (Options);
598 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
599 "Public Class Test1{0}" +
601 " Public Overridable Function Something(ByVal value1 As Object, ByVal value2 As Object, ByRef index As Integer, ByRef count As Integer) As Integer{0}" +
603 "End Class{0}", NewLine), code);
607 public override void MethodMembersTypeTest3 ()
609 string code = GenerateMethodMembersType3 (Options);
610 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
611 "Public Class Test1{0}" +
614 " Public Overridable Function Something(<A(), B()> ByVal value As Object, <C(A1:=false, A2:=true), D()> ByRef __exception As Integer) As Integer{0}" +
616 " Public Overridable Function Something(<A(), B()> ByVal value As Object, <C(A1:=false, A2:=true), D()> ByRef As Integer) As Integer{0}" +
619 "End Class{0}", NewLine), code);
623 public override void MethodImplementationTypes ()
625 string code = GenerateMethodImplementationTypes (Options);
626 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
627 "Public Class Test1{0}" +
630 " Friend Overridable Function Execute() As Integer Implements IPolicy.Execute , IWhatever.Execute{0}" +
632 " Friend Function Execute() As Integer Implements IPolicy.Execute , IWhatever.Execute{0}" +
635 "End Class{0}", NewLine), code);
639 /// Ensure that Overloads keyword is output for a method which has
640 /// explicitly been marked as Overloaded.
643 public override void MethodOverloadsTest1 ()
645 string code = GenerateMethodOverloads1 (Options);
646 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
647 "Public Class Test1{0}" +
650 " Friend Overloads Overridable Function Execute() As Integer{0}" +
652 " Friend Overloads Function Execute() As Integer{0}" +
655 "End Class{0}", NewLine), code);
659 /// Ensure that Overloads keyword is output if multiple methods with
660 /// the same name are defined.
663 public override void MethodOverloadsTest2 ()
665 string code = GenerateMethodOverloads2 (Options);
666 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
667 "Public Class Test1{0}" +
669 " Public Overloads Overridable Sub Execute(){0}" +
672 " Private Overloads Function Execute(ByVal value1 As Object) As Integer{0}" +
674 "End Class{0}", NewLine), code);
678 /// Ensure that a method with a PrivateImplementationType and with
679 /// the same name does not qualify as an overload.
682 public override void MethodOverloadsTest3 ()
684 string code = GenerateMethodOverloads3 (Options);
685 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
686 "Public Class Test1{0}" +
688 " Public Overridable Sub Execute(){0}" +
691 " Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements Integer.Execute{0}" +
693 "End Class{0}", NewLine), code);
697 /// Ensure no access modifiers are output if PrivateImplementationType
701 public override void MethodPrivateImplementationType ()
703 string code = GenerateMethodPrivateImplementationType (Options);
704 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
705 "Public Class Test1{0}" +
707 " Overridable Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements Integer.Execute{0}" +
709 "End Class{0}", NewLine), code);
713 /// If both ImplementationTypes and PrivateImplementationType are set,
714 /// then only ImplementationTypes are output.
717 public override void MethodImplementationTypeOrder ()
719 string code = GenerateMethodImplementationTypeOrder (Options);
720 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
721 "Public Class Test1{0}" +
723 " Overridable Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements IPolicy.Execute{0}" +
725 "End Class{0}", NewLine), code);
729 public override void MethodReturnTypeAttributes ()
731 string code = GenerateMethodReturnTypeAttributes (Options);
732 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
733 "Public Class Test1{0}" +
737 " Public Overridable Function Execute() As <C(A1:=false, A2:=true), D()> Integer{0}" +
739 "End Class{0}", NewLine), code);
743 public override void MethodNewSlotTest ()
745 string code = GenerateMethodNewSlot (Options);
746 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
747 "Public Class Test1{0}" +
749 " Public Shadows Overridable Function Execute() As Integer{0}" +
751 "End Class{0}", NewLine), code);
755 public override void ConstructorAttributesTest ()
757 // FIXME: updated to reflect mbas workaround
758 string code = GenerateConstructorAttributes (Options);
759 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
760 "Public Class Test1{0}" +
764 " Private Sub New(){0}" +
767 "End Class{0}", NewLine), code);
771 public override void ConstructorParametersTest ()
773 // FIXME: updated to reflect mbas workaround
774 string code = GenerateConstructorParameters (Options);
775 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
776 "Public Class Test1{0}" +
778 " Public Sub New(ByVal value1 As Object, ByVal value2 As Object, ByRef index As Integer, ByRef count As Integer){0}" +
781 "End Class{0}", NewLine), code);
785 public override void ConstructorParameterAttributesTest ()
787 // FIXME: updated to reflect mbas workaround
788 string code = GenerateConstructorParameterAttributes (Options);
789 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
790 "Public Class Test1{0}" +
792 " Private Sub New(<A(), B()> ByVal value As Object, <C(A1:=false, A2:=true), D()> ByRef index As Integer){0}" +
795 "End Class{0}", NewLine), code);
799 public override void BaseConstructorSingleArg ()
801 string code = GenerateBaseConstructor (false, Options);
802 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
803 "Public Class Test1{0}" +
805 " Protected Sub New(ByVal value1 As Object, ByRef value2 As Integer){0}" +
806 " MyBase.New(value1){0}" +
808 "End Class{0}", NewLine), code);
812 public override void BaseConstructorMultipleArgs ()
814 string code = GenerateBaseConstructor (true, Options);
815 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
816 "Public Class Test1{0}" +
818 " Protected Sub New(ByVal value1 As Object, ByRef value2 As Integer){0}" +
819 " MyBase.New(value1, value2){0}" +
821 "End Class{0}", NewLine), code);
825 public override void ChainedConstructorSingleArg ()
827 string code = GenerateChainedConstructor (false, Options);
828 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
829 "Public Class Test1{0}" +
831 " Public Sub New(ByVal value1 As Object, ByRef value2 As Integer){0}" +
832 " Me.New(value1){0}" +
834 "End Class{0}", NewLine), code);
838 public override void ChainedConstructorMultipleArgs ()
840 string code = GenerateChainedConstructor (true, Options);
841 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
842 "Public Class Test1{0}" +
844 " Public Sub New(ByVal value1 As Object, ByRef value2 As Integer){0}" +
845 " Me.New(value1, value2){0}" +
847 "End Class{0}", NewLine), code);
851 public override void TypeConstructorTest ()
853 string code = GenerateTypeConstructor (Options);
854 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
855 "Public Class Test1{0}" +
861 " Shared Sub New(){0}" +
863 "End Class{0}", NewLine), code);
867 public override void EntryPointMethodTest ()
869 string code = GenerateEntryPointMethod (Options);
870 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
871 "Public Class Test1{0}" +
876 " Public Shared Sub Main(){0}" +
877 " Dim x As Test.InnerType{0}" +
879 "End Class{0}", NewLine), code);
884 public class CodeGeneratorFromTypeTest_Delegate : CodeGeneratorFromTypeTestBase
886 private CodeTypeDeclaration _typeDeclaration;
887 private ICodeGenerator _codeGenerator;
889 protected override ICodeGenerator CodeGenerator
891 get { return _codeGenerator; }
894 protected override CodeTypeDeclaration TypeDeclaration
896 get { return _typeDeclaration; }
900 public override void SetUp ()
903 _typeDeclaration = new CodeTypeDelegate ();
905 CodeDomProvider provider = new VBCodeProvider ();
906 _codeGenerator = provider.CreateGenerator ();
910 public override void DefaultTypeTest ()
912 string code = GenerateDefaultType (Options);
913 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
914 "Public Delegate Sub (){0}", NewLine), code);
918 [ExpectedException (typeof (NullReferenceException))]
919 public override void NullTypeTest ()
921 GenerateNullType (Options);
925 public override void SimpleTypeTest ()
927 string code = GenerateSimpleType (Options);
928 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
929 "Public Delegate Sub Test1(){0}", NewLine), code);
933 public override void DerivedTypeTest ()
935 string code = GenerateDerivedType (Options);
936 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
937 "Delegate Sub Test1(){0}", NewLine), code);
941 public override void AttributesAndTypeTest ()
943 CodeTypeDelegate delegateDecl = new CodeTypeDelegate ();
944 delegateDecl.ReturnType = new CodeTypeReference (typeof (int));
946 _typeDeclaration = delegateDecl;
948 string code = GenerateAttributesAndType (Options);
949 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
952 "Public Delegate Function Test1() As Integer{0}", NewLine), code);
956 public override void EventMembersTypeTest1 ()
958 string code = GenerateEventMembersType1 (Options);
959 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
960 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
964 public override void EventMembersTypeTest2 ()
966 string code = GenerateEventMembersType2 (Options);
967 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
968 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
972 public override void EventImplementationTypes ()
974 string code = GenerateEventImplementationTypes (Options);
975 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
976 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
980 /// Ensure no access modifiers are output if PrivateImplementationType
984 public override void EventPrivateImplementationType ()
986 string code = GenerateEventPrivateImplementationType (Options);
987 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
988 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
992 /// If both ImplementationTypes and PrivateImplementationType are set,
993 /// then only ImplementationTypes are output.
996 public override void EventImplementationTypeOrder ()
998 string code = GenerateEventImplementationTypeOrder (Options);
999 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1000 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1004 public override void FieldMembersAttributesTest ()
1006 string code = GenerateFieldMembersAttributes (Options);
1007 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1008 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1012 public override void FieldMembersTypeTest ()
1014 string code = GenerateFieldMembersType (MemberAttributes.Public, Options);
1015 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1016 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1020 public override void FieldNewSlotTest ()
1022 string code = GenerateFieldMembersType (MemberAttributes.Assembly |
1023 MemberAttributes.New, Options);
1024 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1025 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1029 public override void PropertyMembersTypeTest1 ()
1031 string code = GeneratePropertyMembersAttributes (Options);
1032 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1033 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1037 public override void PropertyMembersTypeTest2 ()
1039 string code = GeneratePropertyMembersType (MemberAttributes.Public,
1040 false, false, Options);
1041 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1042 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1046 public override void PropertyMembersTypeGetOnly ()
1048 string code = GeneratePropertyMembersType (MemberAttributes.Family,
1049 true, false, Options);
1050 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1051 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1055 public override void PropertyMembersTypeSetOnly ()
1057 string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
1058 false, true, Options);
1059 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1060 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1064 public override void PropertyMembersTypeGetSet ()
1066 string code = GeneratePropertyMembersType (MemberAttributes.Family,
1067 true, true, Options);
1068 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1069 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1073 public override void PropertyMembersTypeFamilyOrAssembly ()
1075 string code = GeneratePropertyMembersType (MemberAttributes.FamilyOrAssembly,
1076 false, false, Options);
1077 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1078 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1082 public override void PropertyMembersTypeAssembly ()
1084 string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
1085 false, false, Options);
1086 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1087 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1091 public override void PropertyParametersTest ()
1093 string code = GeneratePropertyParameters (Options);
1094 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1095 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1099 public override void PropertyIndexerTest1 ()
1101 string code = GeneratePropertyIndexer (MemberAttributes.Public,
1102 false, false, true, Options);
1103 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1104 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1108 public override void PropertyIndexerTest2 ()
1110 string code = GeneratePropertyIndexer (MemberAttributes.Public,
1111 false, false, false, Options);
1112 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1113 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1117 public override void PropertyIndexerGetOnly ()
1119 string code = GeneratePropertyIndexer (MemberAttributes.Family,
1120 true, false, true, Options);
1121 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1122 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1126 public override void PropertyIndexerSetOnly ()
1128 string code = GeneratePropertyIndexer (MemberAttributes.Family,
1129 false, true, true, Options);
1130 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1131 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1135 public override void PropertyImplementationTypes ()
1137 string code = GeneratePropertyImplementationTypes (Options);
1138 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1139 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1143 public override void PropertyOverloadsTest1 ()
1145 string code = GeneratePropertyOverloads1 (Options);
1146 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1147 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1151 public override void PropertyOverloadsTest2 ()
1153 string code = GeneratePropertyOverloads2 (Options);
1154 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1155 "Public Delegate Sub Test1(){0}{0}{0}", NewLine), code);
1159 public override void PropertyOverloadsTest3 ()
1161 string code = GeneratePropertyOverloads3 (Options);
1162 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1163 "Public Delegate Sub Test1(){0}{0}{0}", NewLine), code);
1167 public override void PropertyPrivateImplementationType ()
1169 string code = GeneratePropertyPrivateImplementationType (Options);
1170 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1171 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1175 public override void PropertyImplementationTypeOrder ()
1177 string code = GeneratePropertyImplementationTypeOrder (Options);
1178 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1179 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1183 public override void PropertyNewSlotTest ()
1185 string code = GeneratePropertyMembersType (MemberAttributes.Private |
1186 MemberAttributes.New, true, true, Options);
1187 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1188 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1192 public override void MethodMembersTypeTest1 ()
1194 string code = GenerateMethodMembersType1 (Options);
1195 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1196 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1200 public override void MethodMembersTypeTest2 ()
1202 string code = GenerateMethodMembersType2 (Options);
1203 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1204 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1208 public override void MethodMembersTypeTest3 ()
1210 string code = GenerateMethodMembersType3 (Options);
1211 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1212 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1216 public override void MethodImplementationTypes ()
1218 string code = GenerateMethodImplementationTypes (Options);
1219 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1220 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1224 public override void MethodOverloadsTest1 ()
1226 string code = GenerateMethodOverloads1 (Options);
1227 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1228 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1232 public override void MethodOverloadsTest2 ()
1234 string code = GenerateMethodOverloads2 (Options);
1235 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1236 "Public Delegate Sub Test1(){0}{0}{0}", NewLine), code);
1240 public override void MethodOverloadsTest3 ()
1242 string code = GenerateMethodOverloads3 (Options);
1243 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1244 "Public Delegate Sub Test1(){0}{0}{0}", NewLine), code);
1248 public override void MethodPrivateImplementationType ()
1250 string code = GenerateMethodPrivateImplementationType (Options);
1251 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1252 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1256 public override void MethodImplementationTypeOrder ()
1258 string code = GenerateMethodImplementationTypeOrder (Options);
1259 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1260 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1264 public override void MethodReturnTypeAttributes ()
1266 string code = GenerateMethodReturnTypeAttributes (Options);
1267 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1268 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1272 public override void MethodNewSlotTest ()
1274 string code = GenerateMethodNewSlot (Options);
1275 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1276 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1280 public override void ConstructorAttributesTest ()
1282 string code = GenerateConstructorAttributes (Options);
1283 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1284 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1288 public override void ConstructorParametersTest ()
1290 string code = GenerateConstructorParameters (Options);
1291 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1292 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1296 public override void ConstructorParameterAttributesTest ()
1298 string code = GenerateConstructorParameterAttributes (Options);
1299 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1300 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1304 public override void BaseConstructorSingleArg ()
1306 string code = GenerateBaseConstructor (false, Options);
1307 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1308 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1312 public override void BaseConstructorMultipleArgs ()
1314 string code = GenerateBaseConstructor (true, Options);
1315 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1316 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1320 public override void ChainedConstructorSingleArg ()
1322 string code = GenerateChainedConstructor (false, Options);
1323 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1324 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1328 public override void ChainedConstructorMultipleArgs ()
1330 string code = GenerateChainedConstructor (true, Options);
1331 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1332 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1336 public override void TypeConstructorTest ()
1338 string code = GenerateTypeConstructor (Options);
1339 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1340 "Public Delegate Sub Test1(){0}{0}", NewLine), code);
1344 public override void EntryPointMethodTest ()
1346 string code = GenerateEntryPointMethod (Options);
1347 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1348 "Public Delegate Sub Test1(){0}{0}" +
1352 "Public Shared Sub Main(){0}" +
1353 " Dim x As Test.InnerType{0}" +
1354 "End Sub{0}", NewLine), code);
1359 public class CodeGeneratorFromTypeTest_Interface : CodeGeneratorFromTypeTestBase
1361 private CodeTypeDeclaration _typeDeclaration;
1362 private ICodeGenerator _codeGenerator;
1364 protected override ICodeGenerator CodeGenerator
1366 get { return _codeGenerator; }
1369 protected override CodeTypeDeclaration TypeDeclaration
1371 get { return _typeDeclaration; }
1375 public override void SetUp ()
1378 _typeDeclaration = new CodeTypeDeclaration ();
1379 _typeDeclaration.IsInterface = true;
1381 CodeDomProvider provider = new VBCodeProvider ();
1382 _codeGenerator = provider.CreateGenerator ();
1386 public override void DefaultTypeTest ()
1388 string code = GenerateDefaultType (Options);
1389 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1390 "Public Interface {0}" +
1391 "End Interface{0}", NewLine), code);
1395 [ExpectedException (typeof (NullReferenceException))]
1396 public override void NullTypeTest ()
1398 GenerateNullType (Options);
1402 public override void SimpleTypeTest ()
1404 string code = GenerateSimpleType (Options);
1405 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1406 "Public Interface Test1{0}" +
1407 "End Interface{0}", NewLine), code);
1411 public override void DerivedTypeTest ()
1413 string code = GenerateDerivedType (Options);
1414 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1416 "Friend Interface Test1{0}" +
1418 "Interface Test1{0}" +
1420 " Inherits Integer, System.Security.Principal.IIdentity, String, System.Security.IPermission{0}" +
1421 "End Interface{0}", NewLine), code);
1425 public override void AttributesAndTypeTest ()
1427 string code = GenerateAttributesAndType (Options);
1428 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1431 "Public Interface Test1{0}" +
1432 "End Interface{0}", NewLine), code);
1436 public override void EventMembersTypeTest1 ()
1438 string code = GenerateEventMembersType1 (Options);
1439 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1440 "Public Interface Test1{0}" +
1445 " Private Event __exception As System.Void{0}" +
1447 " Private Event As System.Void{0}" +
1449 "End Interface{0}", NewLine), code);
1453 public override void EventMembersTypeTest2 ()
1455 string code = GenerateEventMembersType2 (Options);
1456 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1457 "Public Interface Test1{0}" +
1459 " Public Event Click As Integer{0}" +
1460 "End Interface{0}", NewLine), code);
1464 public override void EventImplementationTypes ()
1466 string code = GenerateEventImplementationTypes (Options);
1467 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1468 "Public Interface Test1{0}" +
1471 " Friend Event Click As Integer Implements IPolicy.Click , IWhatever.Click{0}" +
1473 " Friend Event Click As Integer{0}" +
1475 "End Interface{0}", NewLine), code);
1479 public override void EventPrivateImplementationType ()
1481 string code = GenerateEventPrivateImplementationType (Options);
1482 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1483 "Public Interface Test1{0}" +
1486 " Protected Event System_Int32_Click As Integer Implements Integer.Click{0}" +
1488 " Protected Event Click As Integer{0}" +
1490 "End Interface{0}", NewLine), code);
1494 public override void EventImplementationTypeOrder ()
1496 string code = GenerateEventImplementationTypeOrder (Options);
1497 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1498 "Public Interface Test1{0}" +
1501 " Public Event System_Int32_Click As Integer Implements IPolicy.Click{0}" +
1503 " Public Event Click As Integer{0}" +
1505 "End Interface{0}", NewLine), code);
1509 public override void FieldMembersAttributesTest ()
1511 string code = GenerateFieldMembersAttributes (Options);
1512 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1513 "Public Interface Test1{0}" +
1515 "End Interface{0}", NewLine), code);
1519 public override void FieldMembersTypeTest ()
1521 string code = GenerateFieldMembersType (MemberAttributes.Public, Options);
1522 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1523 "Public Interface Test1{0}" +
1525 "End Interface{0}", NewLine), code);
1529 public override void FieldNewSlotTest ()
1531 string code = GenerateFieldMembersType (MemberAttributes.Assembly |
1532 MemberAttributes.New, Options);
1533 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1534 "Public Interface Test1{0}" +
1536 "End Interface{0}", NewLine), code);
1540 public override void PropertyMembersTypeTest1 ()
1542 string code = GeneratePropertyMembersAttributes (Options);
1543 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1544 "Public Interface Test1{0}" +
1549 " Property () As System.Void{0}" +
1551 " Property As System.Void{0}" +
1553 "End Interface{0}", NewLine), code);
1557 public override void PropertyMembersTypeTest2 ()
1559 string code = GeneratePropertyMembersType (MemberAttributes.Public,
1560 false, false, Options);
1561 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1562 "Public Interface Test1{0}" +
1565 " Property Name() As Integer{0}" +
1567 " Property Name As Integer{0}" +
1569 "End Interface{0}", NewLine), code);
1573 public override void PropertyMembersTypeGetOnly ()
1575 string code = GeneratePropertyMembersType (MemberAttributes.Family,
1576 true, false, Options);
1577 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1578 "Public Interface Test1{0}" +
1581 " ReadOnly Property Name() As Integer{0}" +
1583 " ReadOnly Property Name As Integer{0}" +
1585 "End Interface{0}", NewLine), code);
1589 public override void PropertyMembersTypeSetOnly ()
1591 string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
1592 false, true, Options);
1593 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1594 "Public Interface Test1{0}" +
1597 " WriteOnly Property Name() As Integer{0}" +
1599 " WriteOnly Property Name As Integer{0}" +
1601 "End Interface{0}", NewLine), code);
1605 public override void PropertyMembersTypeGetSet ()
1607 string code = GeneratePropertyMembersType (MemberAttributes.Family,
1608 true, true, Options);
1609 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1610 "Public Interface Test1{0}" +
1613 " Property Name() As Integer{0}" +
1615 " Property Name As Integer{0}" +
1617 "End Interface{0}", NewLine), code);
1621 public override void PropertyMembersTypeFamilyOrAssembly ()
1623 string code = GeneratePropertyMembersType (MemberAttributes.FamilyOrAssembly,
1624 false, false, Options);
1625 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1626 "Public Interface Test1{0}" +
1629 " Property Name() As Integer{0}" +
1631 " Property Name As Integer{0}" +
1633 "End Interface{0}", NewLine), code);
1637 public override void PropertyMembersTypeAssembly ()
1639 string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
1640 false, false, Options);
1641 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1642 "Public Interface Test1{0}" +
1645 " Property Name() As Integer{0}" +
1647 " Property Name As Integer{0}" +
1649 "End Interface{0}", NewLine), code);
1653 public override void PropertyParametersTest ()
1655 string code = GeneratePropertyParameters (Options);
1656 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1657 "Public Interface Test1{0}" +
1659 " Property Name(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
1660 "End Interface{0}", NewLine), code);
1664 public override void PropertyIndexerTest1 ()
1666 string code = GeneratePropertyIndexer (MemberAttributes.Public,
1667 false, false, true, Options);
1668 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1669 "Public Interface Test1{0}" +
1671 " Default Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
1672 "End Interface{0}", NewLine), code);
1676 public override void PropertyIndexerTest2 ()
1678 string code = GeneratePropertyIndexer (MemberAttributes.Public,
1679 false, false, false, Options);
1680 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1681 "Public Interface Test1{0}" +
1684 " Property iTem() As Integer{0}" +
1686 " Property iTem As Integer{0}" +
1688 "End Interface{0}", NewLine), code);
1692 public override void PropertyIndexerGetOnly ()
1694 string code = GeneratePropertyIndexer (MemberAttributes.Family,
1695 true, false, true, Options);
1696 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1697 "Public Interface Test1{0}" +
1699 " Default ReadOnly Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
1700 "End Interface{0}", NewLine), code);
1704 public override void PropertyIndexerSetOnly ()
1706 string code = GeneratePropertyIndexer (MemberAttributes.Family,
1707 false, true, true, Options);
1708 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1709 "Public Interface Test1{0}" +
1711 " Default WriteOnly Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
1712 "End Interface{0}", NewLine), code);
1716 public override void PropertyImplementationTypes ()
1718 string code = GeneratePropertyImplementationTypes (Options);
1719 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1720 "Public Interface Test1{0}" +
1723 " Property Name() As Integer Implements IPolicy.Name , IWhatever.Name{0}" +
1725 " Property Name As Integer Implements IPolicy.Name , IWhatever.Name{0}" +
1727 "End Interface{0}", NewLine), code);
1731 public override void PropertyOverloadsTest1 ()
1733 string code = GeneratePropertyOverloads1 (Options);
1734 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1735 "Public Interface Test1{0}" +
1738 " Property Name() As Integer{0}" +
1740 " Property Name As Integer{0}" +
1742 "End Interface{0}", NewLine), code);
1746 public override void PropertyOverloadsTest2 ()
1748 string code = GeneratePropertyOverloads2 (Options);
1749 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1750 "Public Interface Test1{0}" +
1753 " Property Name() As Integer{0}" +
1755 " Property Name As Integer{0}" +
1758 " Property Name(ByVal value1 As Object) As Integer{0}" +
1759 "End Interface{0}", NewLine), code);
1763 public override void PropertyOverloadsTest3 ()
1765 string code = GeneratePropertyOverloads3 (Options);
1766 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1767 "Public Interface Test1{0}" +
1770 " Property Name() As Integer{0}" +
1772 " Property Name As Integer{0}" +
1775 " Property System_Int32_Name(ByVal value1 As Object) As Integer Implements Integer.Name{0}" +
1776 "End Interface{0}", NewLine), code);
1780 public override void PropertyPrivateImplementationType ()
1782 string code = GeneratePropertyPrivateImplementationType (Options);
1783 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1784 "Public Interface Test1{0}" +
1786 " Property System_Int32_Item(ByVal value1 As Object) As Integer Implements Integer.Item{0}" +
1787 "End Interface{0}", NewLine), code);
1791 public override void PropertyImplementationTypeOrder ()
1793 string code = GeneratePropertyImplementationTypeOrder (Options);
1794 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1795 "Public Interface Test1{0}" +
1797 " Property System_Int32_Item(ByVal value1 As Object) As Integer Implements IPolicy.Item{0}" +
1798 "End Interface{0}", NewLine), code);
1802 public override void PropertyNewSlotTest ()
1804 string code = GeneratePropertyMembersType (MemberAttributes.Private |
1805 MemberAttributes.New, true, true, Options);
1806 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1807 "Public Interface Test1{0}" +
1810 " Shadows Property Name() As Integer{0}" +
1812 " Shadows Property Name As Integer{0}" +
1814 "End Interface{0}", NewLine), code);
1818 public override void MethodMembersTypeTest1 ()
1820 string code = GenerateMethodMembersType1 (Options);
1821 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1822 "Public Interface Test1{0}" +
1827 "End Interface{0}", NewLine), code);
1831 public override void MethodMembersTypeTest2 ()
1833 string code = GenerateMethodMembersType2 (Options);
1834 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1835 "Public Interface Test1{0}" +
1837 " Function Something(ByVal value1 As Object, ByVal value2 As Object, ByRef index As Integer, ByRef count As Integer) As Integer{0}" +
1838 "End Interface{0}", NewLine), code);
1842 public override void MethodMembersTypeTest3 ()
1844 string code = GenerateMethodMembersType3 (Options);
1845 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1846 "Public Interface Test1{0}" +
1849 " Function Something(<A(), B()> ByVal value As Object, <C(A1:=false, A2:=true), D()> ByRef __exception As Integer) As Integer{0}" +
1851 " Function Something(<A(), B()> ByVal value As Object, <C(A1:=false, A2:=true), D()> ByRef As Integer) As Integer{0}" +
1853 "End Interface{0}", NewLine), code);
1857 public override void MethodImplementationTypes ()
1859 string code = GenerateMethodImplementationTypes (Options);
1860 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1861 "Public Interface Test1{0}" +
1863 " Function Execute() As Integer Implements IPolicy.Execute , IWhatever.Execute{0}" +
1864 "End Interface{0}", NewLine), code);
1868 public override void MethodOverloadsTest1 ()
1870 string code = GenerateMethodOverloads1 (Options);
1871 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1872 "Public Interface Test1{0}" +
1874 " Function Execute() As Integer{0}" +
1875 "End Interface{0}", NewLine), code);
1879 public override void MethodOverloadsTest2 ()
1881 string code = GenerateMethodOverloads2 (Options);
1882 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1883 "Public Interface Test1{0}" +
1885 " Sub Execute(){0}" +
1887 " Function Execute(ByVal value1 As Object) As Integer{0}" +
1888 "End Interface{0}", NewLine), code);
1892 public override void MethodOverloadsTest3 ()
1894 string code = GenerateMethodOverloads3 (Options);
1895 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1896 "Public Interface Test1{0}" +
1898 " Sub Execute(){0}" +
1900 " Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements Integer.Execute{0}" +
1901 "End Interface{0}", NewLine), code);
1905 public override void MethodPrivateImplementationType ()
1907 string code = GenerateMethodPrivateImplementationType (Options);
1908 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1909 "Public Interface Test1{0}" +
1911 " Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements Integer.Execute{0}" +
1912 "End Interface{0}", NewLine), code);
1916 public override void MethodImplementationTypeOrder ()
1918 string code = GenerateMethodImplementationTypeOrder (Options);
1919 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1920 "Public Interface Test1{0}" +
1922 " Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements IPolicy.Execute{0}" +
1923 "End Interface{0}", NewLine), code);
1927 public override void MethodReturnTypeAttributes ()
1929 string code = GenerateMethodReturnTypeAttributes (Options);
1930 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1931 "Public Interface Test1{0}" +
1935 " Function Execute() As <C(A1:=false, A2:=true), D()> Integer{0}" +
1936 "End Interface{0}", NewLine), code);
1940 public override void MethodNewSlotTest ()
1942 string code = GenerateMethodNewSlot (Options);
1943 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1944 "Public Interface Test1{0}" +
1946 " Shadows Function Execute() As Integer{0}" +
1947 "End Interface{0}", NewLine), code);
1951 public override void ConstructorAttributesTest ()
1953 string code = GenerateConstructorAttributes (Options);
1954 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1955 "Public Interface Test1{0}" +
1957 "End Interface{0}", NewLine), code);
1961 public override void ConstructorParametersTest ()
1963 string code = GenerateConstructorParameters (Options);
1964 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1965 "Public Interface Test1{0}" +
1967 "End Interface{0}", NewLine), code);
1971 public override void ConstructorParameterAttributesTest ()
1973 string code = GenerateConstructorParameterAttributes (Options);
1974 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1975 "Public Interface Test1{0}" +
1977 "End Interface{0}", NewLine), code);
1981 public override void BaseConstructorSingleArg ()
1983 string code = GenerateBaseConstructor (false, Options);
1984 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1985 "Public Interface Test1{0}" +
1987 "End Interface{0}", NewLine), code);
1991 public override void BaseConstructorMultipleArgs ()
1993 string code = GenerateBaseConstructor (true, Options);
1994 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1995 "Public Interface Test1{0}" +
1997 "End Interface{0}", NewLine), code);
2001 public override void ChainedConstructorSingleArg ()
2003 string code = GenerateChainedConstructor (false, Options);
2004 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2005 "Public Interface Test1{0}" +
2007 "End Interface{0}", NewLine), code);
2011 public override void ChainedConstructorMultipleArgs ()
2013 string code = GenerateChainedConstructor (true, Options);
2014 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2015 "Public Interface Test1{0}" +
2017 "End Interface{0}", NewLine), code);
2021 public override void TypeConstructorTest ()
2023 string code = GenerateTypeConstructor (Options);
2024 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2025 "Public Interface Test1{0}" +
2027 "End Interface{0}", NewLine), code);
2031 public override void EntryPointMethodTest ()
2033 string code = GenerateEntryPointMethod (Options);
2034 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2035 "Public Interface Test1{0}" +
2040 " Public Shared Sub Main(){0}" +
2041 " Dim x As Test.InnerType{0}" +
2043 "End Interface{0}", NewLine), code);
2048 public class CodeGeneratorFromTypeTest_Struct : CodeGeneratorFromTypeTestBase
2050 private CodeTypeDeclaration _typeDeclaration;
2051 private ICodeGenerator _codeGenerator;
2053 protected override ICodeGenerator CodeGenerator
2055 get { return _codeGenerator; }
2058 protected override CodeTypeDeclaration TypeDeclaration
2060 get { return _typeDeclaration; }
2064 public override void SetUp ()
2067 _typeDeclaration = new CodeTypeDeclaration ();
2068 _typeDeclaration.IsStruct = true;
2070 CodeDomProvider provider = new VBCodeProvider ();
2071 _codeGenerator = provider.CreateGenerator ();
2075 public override void DefaultTypeTest ()
2077 string code = GenerateDefaultType (Options);
2078 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2079 "Public Structure {0}" +
2080 "End Structure{0}", NewLine), code);
2084 [ExpectedException (typeof (NullReferenceException))]
2085 public override void NullTypeTest ()
2087 GenerateNullType (Options);
2091 public override void SimpleTypeTest ()
2093 string code = GenerateSimpleType (Options);
2094 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2095 "Public Structure Test1{0}" +
2096 "End Structure{0}", NewLine), code);
2100 public override void DerivedTypeTest ()
2102 string code = GenerateDerivedType (Options);
2103 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2105 "Friend Structure Test1{0}" +
2107 "Structure Test1{0}" +
2109 " Implements Integer, System.Security.Principal.IIdentity, String, System.Security.IPermission{0}" +
2110 "End Structure{0}", NewLine), code);
2114 public override void AttributesAndTypeTest ()
2116 string code = GenerateAttributesAndType (Options);
2117 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2120 "Public Structure Test1{0}" +
2121 "End Structure{0}", NewLine), code);
2125 public override void EventMembersTypeTest1 ()
2127 string code = GenerateEventMembersType1 (Options);
2128 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2129 "Public Structure Test1{0}" +
2134 " Private Event __exception As System.Void{0}" +
2136 " Private Event As System.Void{0}" +
2138 "End Structure{0}", NewLine), code);
2142 public override void EventMembersTypeTest2 ()
2144 string code = GenerateEventMembersType2 (Options);
2145 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2146 "Public Structure Test1{0}" +
2148 " Public Event Click As Integer{0}" +
2149 "End Structure{0}", NewLine), code);
2153 public override void EventImplementationTypes ()
2155 string code = GenerateEventImplementationTypes (Options);
2156 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2157 "Public Structure Test1{0}" +
2160 " Friend Event Click As Integer Implements IPolicy.Click , IWhatever.Click{0}" +
2162 " Friend Event Click As Integer{0}" +
2164 "End Structure{0}", NewLine), code);
2168 public override void EventPrivateImplementationType ()
2170 string code = GenerateEventPrivateImplementationType (Options);
2171 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2172 "Public Structure Test1{0}" +
2175 " Protected Event System_Int32_Click As Integer Implements Integer.Click{0}" +
2177 " Protected Event Click As Integer{0}" +
2179 "End Structure{0}", NewLine), code);
2183 public override void EventImplementationTypeOrder ()
2185 string code = GenerateEventImplementationTypeOrder (Options);
2186 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2187 "Public Structure Test1{0}" +
2190 " Public Event System_Int32_Click As Integer Implements IPolicy.Click{0}" +
2192 " Public Event Click As Integer{0}" +
2194 "End Structure{0}", NewLine), code);
2198 public override void FieldMembersAttributesTest ()
2200 string code = GenerateFieldMembersAttributes (Options);
2201 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2202 "Public Structure Test1{0}" +
2207 " Private __exception As System.Void{0}" +
2209 " Private As System.Void{0}" +
2211 "End Structure{0}", NewLine), code);
2215 public override void FieldMembersTypeTest ()
2217 string code = GenerateFieldMembersType (MemberAttributes.Public, Options);
2218 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2219 "Public Structure Test1{0}" +
2221 " Public Name As Integer = 2{0}" +
2222 "End Structure{0}", NewLine), code);
2226 public override void FieldNewSlotTest ()
2228 string code = GenerateFieldMembersType (MemberAttributes.Assembly |
2229 MemberAttributes.New, Options);
2230 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2231 "Public Structure Test1{0}" +
2233 " Friend Shadows Name As Integer = 2{0}" +
2234 "End Structure{0}", NewLine), code);
2238 public override void PropertyMembersTypeTest1 ()
2240 string code = GeneratePropertyMembersAttributes (Options);
2241 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2242 "Public Structure Test1{0}" +
2247 " Private Property () As System.Void{0}" +
2249 " Private Property As System.Void{0}" +
2251 " End Property{0}" +
2252 "End Structure{0}", NewLine), code);
2256 public override void PropertyMembersTypeTest2 ()
2258 string code = GeneratePropertyMembersType (MemberAttributes.Public,
2259 false, false, Options);
2260 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2261 "Public Structure Test1{0}" +
2264 " Public Overridable Property Name() As Integer{0}" +
2266 " Public Overridable Property Name As Integer{0}" +
2268 " End Property{0}" +
2269 "End Structure{0}", NewLine), code);
2273 public override void PropertyMembersTypeGetOnly ()
2275 string code = GeneratePropertyMembersType (MemberAttributes.Family,
2276 true, false, Options);
2277 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2278 "Public Structure Test1{0}" +
2281 " Protected Overridable ReadOnly Property Name() As Integer{0}" +
2283 " Protected Overridable ReadOnly Property Name As Integer{0}" +
2287 " End Property{0}" +
2288 "End Structure{0}", NewLine), code);
2292 public override void PropertyMembersTypeSetOnly ()
2294 string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
2295 false, true, Options);
2296 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2297 "Public Structure Test1{0}" +
2300 " Friend Overridable WriteOnly Property Name() As Integer{0}" +
2302 " Friend WriteOnly Property Name As Integer{0}" +
2306 " End Property{0}" +
2307 "End Structure{0}", NewLine), code);
2311 public override void PropertyMembersTypeGetSet ()
2313 string code = GeneratePropertyMembersType (MemberAttributes.Family,
2314 true, true, Options);
2315 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2316 "Public Structure Test1{0}" +
2319 " Protected Overridable Property Name() As Integer{0}" +
2321 " Protected Overridable Property Name As Integer{0}" +
2327 " End Property{0}" +
2328 "End Structure{0}", NewLine), code);
2332 // A bug in MS.NET 1.x causes MemberAttributes.FamilyOrAssembly to be
2333 // generated as Protected
2334 [Category ("NotDotNet")]
2337 public override void PropertyMembersTypeFamilyOrAssembly ()
2339 string code = GeneratePropertyMembersType (MemberAttributes.FamilyOrAssembly,
2340 false, false, Options);
2341 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2342 "Public Structure Test1{0}" +
2345 " Protected Friend Property Name() As Integer{0}" +
2347 " Protected Friend Property Name As Integer{0}" +
2349 " End Property{0}" +
2350 "End Structure{0}", NewLine), code);
2354 public override void PropertyMembersTypeAssembly ()
2356 string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
2357 false, false, Options);
2358 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2359 "Public Structure Test1{0}" +
2362 " Friend Overridable Property Name() As Integer{0}" +
2364 " Friend Property Name As Integer{0}" +
2366 " End Property{0}" +
2367 "End Structure{0}", NewLine), code);
2371 public override void PropertyParametersTest ()
2373 string code = GeneratePropertyParameters (Options);
2374 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2375 "Public Structure Test1{0}" +
2377 " Public Overridable Property Name(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
2378 " End Property{0}" +
2379 "End Structure{0}", NewLine), code);
2383 public override void PropertyIndexerTest1 ()
2385 string code = GeneratePropertyIndexer (MemberAttributes.Public,
2386 false, false, true, Options);
2387 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2388 "Public Structure Test1{0}" +
2390 " Public Overridable Default Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
2391 " End Property{0}" +
2392 "End Structure{0}", NewLine), code);
2396 public override void PropertyIndexerTest2 ()
2398 string code = GeneratePropertyIndexer (MemberAttributes.Public,
2399 false, false, false, Options);
2400 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2401 "Public Structure Test1{0}" +
2404 " Public Overridable Property iTem() As Integer{0}" +
2406 " Public Overridable Property iTem As Integer{0}" +
2408 " End Property{0}" +
2409 "End Structure{0}", NewLine), code);
2413 public override void PropertyIndexerGetOnly ()
2415 string code = GeneratePropertyIndexer (MemberAttributes.Family,
2416 true, false, true, Options);
2417 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2418 "Public Structure Test1{0}" +
2420 " Protected Overridable Default ReadOnly Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
2423 " End Property{0}" +
2424 "End Structure{0}", NewLine), code);
2428 public override void PropertyIndexerSetOnly ()
2430 string code = GeneratePropertyIndexer (MemberAttributes.Family,
2431 false, true, true, Options);
2432 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2433 "Public Structure Test1{0}" +
2435 " Protected Overridable Default WriteOnly Property iTem(ByVal value1 As Object, ByRef value2 As Integer) As Integer{0}" +
2438 " End Property{0}" +
2439 "End Structure{0}", NewLine), code);
2443 public override void PropertyImplementationTypes ()
2445 string code = GeneratePropertyImplementationTypes (Options);
2446 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2447 "Public Structure Test1{0}" +
2450 " Public Overridable Property Name() As Integer Implements IPolicy.Name , IWhatever.Name{0}" +
2452 " Public Overridable Property Name As Integer Implements IPolicy.Name , IWhatever.Name{0}" +
2454 " End Property{0}" +
2455 "End Structure{0}", NewLine), code);
2459 public override void PropertyOverloadsTest1 ()
2461 string code = GeneratePropertyOverloads1 (Options);
2462 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2463 "Public Structure Test1{0}" +
2466 " Protected Overloads Overridable Property Name() As Integer{0}" +
2468 " Protected Overloads Overridable Property Name As Integer{0}" +
2470 " End Property{0}" +
2471 "End Structure{0}", NewLine), code);
2475 public override void PropertyOverloadsTest2 ()
2477 string code = GeneratePropertyOverloads2 (Options);
2478 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2479 "Public Structure Test1{0}" +
2482 " Public Overloads Overridable Property Name() As Integer{0}" +
2484 " Public Overloads Overridable Property Name As Integer{0}" +
2486 " End Property{0}" +
2488 " Private Overloads Property Name(ByVal value1 As Object) As Integer{0}" +
2489 " End Property{0}" +
2490 "End Structure{0}", NewLine), code);
2494 public override void PropertyOverloadsTest3 ()
2496 string code = GeneratePropertyOverloads3 (Options);
2497 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2498 "Public Structure Test1{0}" +
2501 " Public Overridable Property Name() As Integer{0}" +
2503 " Public Overridable Property Name As Integer{0}" +
2505 " End Property{0}" +
2507 " Property System_Int32_Name(ByVal value1 As Object) As Integer Implements Integer.Name{0}" +
2508 " End Property{0}" +
2509 "End Structure{0}", NewLine), code);
2513 public override void PropertyPrivateImplementationType ()
2515 string code = GeneratePropertyPrivateImplementationType (Options);
2516 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2517 "Public Structure Test1{0}" +
2519 " Overridable Property System_Int32_Item(ByVal value1 As Object) As Integer Implements Integer.Item{0}" +
2520 " End Property{0}" +
2521 "End Structure{0}", NewLine), code);
2525 public override void PropertyImplementationTypeOrder ()
2527 string code = GeneratePropertyImplementationTypeOrder (Options);
2528 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2529 "Public Structure Test1{0}" +
2531 " Overridable Property System_Int32_Item(ByVal value1 As Object) As Integer Implements IPolicy.Item{0}" +
2532 " End Property{0}" +
2533 "End Structure{0}", NewLine), code);
2537 public override void PropertyNewSlotTest ()
2539 string code = GeneratePropertyMembersType (MemberAttributes.Private |
2540 MemberAttributes.New, true, true, Options);
2541 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2542 "Public Structure Test1{0}" +
2545 " Private Shadows Property Name() As Integer{0}" +
2547 " Private Shadows Property Name As Integer{0}" +
2553 " End Property{0}" +
2554 "End Structure{0}", NewLine), code);
2558 public override void MethodMembersTypeTest1 ()
2560 string code = GenerateMethodMembersType1 (Options);
2561 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2562 "Public Structure Test1{0}" +
2566 " Private Sub (){0}" +
2568 "End Structure{0}", NewLine), code);
2572 public override void MethodMembersTypeTest2 ()
2574 string code = GenerateMethodMembersType2 (Options);
2575 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2576 "Public Structure Test1{0}" +
2578 " Public Overridable Function Something(ByVal value1 As Object, ByVal value2 As Object, ByRef index As Integer, ByRef count As Integer) As Integer{0}" +
2579 " End Function{0}" +
2580 "End Structure{0}", NewLine), code);
2584 public override void MethodMembersTypeTest3 ()
2586 string code = GenerateMethodMembersType3 (Options);
2587 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2588 "Public Structure Test1{0}" +
2591 " Public Overridable Function Something(<A(), B()> ByVal value As Object, <C(A1:=false, A2:=true), D()> ByRef __exception As Integer) As Integer{0}" +
2593 " Public Overridable Function Something(<A(), B()> ByVal value As Object, <C(A1:=false, A2:=true), D()> ByRef As Integer) As Integer{0}" +
2595 " End Function{0}" +
2596 "End Structure{0}", NewLine), code);
2600 public override void MethodImplementationTypes ()
2602 string code = GenerateMethodImplementationTypes (Options);
2603 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2604 "Public Structure Test1{0}" +
2607 " Friend Overridable Function Execute() As Integer Implements IPolicy.Execute , IWhatever.Execute{0}" +
2609 " Friend Function Execute() As Integer Implements IPolicy.Execute , IWhatever.Execute{0}" +
2611 " End Function{0}" +
2612 "End Structure{0}", NewLine), code);
2616 public override void MethodOverloadsTest1 ()
2618 string code = GenerateMethodOverloads1 (Options);
2619 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2620 "Public Structure Test1{0}" +
2623 " Friend Overloads Overridable Function Execute() As Integer{0}" +
2625 " Friend Overloads Function Execute() As Integer{0}" +
2627 " End Function{0}" +
2628 "End Structure{0}", NewLine), code);
2632 public override void MethodOverloadsTest2 ()
2634 string code = GenerateMethodOverloads2 (Options);
2635 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2636 "Public Structure Test1{0}" +
2638 " Public Overloads Overridable Sub Execute(){0}" +
2641 " Private Overloads Function Execute(ByVal value1 As Object) As Integer{0}" +
2642 " End Function{0}" +
2643 "End Structure{0}", NewLine), code);
2647 public override void MethodOverloadsTest3 ()
2649 string code = GenerateMethodOverloads3 (Options);
2650 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2651 "Public Structure Test1{0}" +
2653 " Public Overridable Sub Execute(){0}" +
2656 " Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements Integer.Execute{0}" +
2657 " End Function{0}" +
2658 "End Structure{0}", NewLine), code);
2662 public override void MethodPrivateImplementationType ()
2664 string code = GenerateMethodPrivateImplementationType (Options);
2665 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2666 "Public Structure Test1{0}" +
2668 " Overridable Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements Integer.Execute{0}" +
2669 " End Function{0}" +
2670 "End Structure{0}", NewLine), code);
2674 public override void MethodImplementationTypeOrder ()
2676 string code = GenerateMethodImplementationTypeOrder (Options);
2677 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2678 "Public Structure Test1{0}" +
2680 " Overridable Function System_Int32_Execute(ByVal value1 As Object) As Integer Implements IPolicy.Execute{0}" +
2681 " End Function{0}" +
2682 "End Structure{0}", NewLine), code);
2686 public override void MethodReturnTypeAttributes ()
2688 string code = GenerateMethodReturnTypeAttributes (Options);
2689 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2690 "Public Structure Test1{0}" +
2694 " Public Overridable Function Execute() As <C(A1:=false, A2:=true), D()> Integer{0}" +
2695 " End Function{0}" +
2696 "End Structure{0}", NewLine), code);
2700 public override void MethodNewSlotTest ()
2702 string code = GenerateMethodNewSlot (Options);
2703 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2704 "Public Structure Test1{0}" +
2706 " Public Shadows Overridable Function Execute() As Integer{0}" +
2707 " End Function{0}" +
2708 "End Structure{0}", NewLine), code);
2712 public override void ConstructorAttributesTest ()
2714 // FIXME: updated to reflect mbas workaround
2715 string code = GenerateConstructorAttributes (Options);
2716 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2717 "Public Structure Test1{0}" +
2721 " Private Sub New(){0}" +
2723 " MyBase.New(){0}" +
2726 "End Structure{0}", NewLine), code);
2730 public override void ConstructorParametersTest ()
2732 // FIXME: updated to reflect mbas workaround
2733 string code = GenerateConstructorParameters (Options);
2734 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2735 "Public Structure Test1{0}" +
2737 " Public Sub New(ByVal value1 As Object, ByVal value2 As Object, ByRef index As Integer, ByRef count As Integer){0}" +
2739 " MyBase.New(){0}" +
2742 "End Structure{0}", NewLine), code);
2746 public override void ConstructorParameterAttributesTest ()
2748 // FIXME: updated to reflect mbas workaround
2749 string code = GenerateConstructorParameterAttributes (Options);
2750 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2751 "Public Structure Test1{0}" +
2753 " Private Sub New(<A(), B()> ByVal value As Object, <C(A1:=false, A2:=true), D()> ByRef index As Integer){0}" +
2755 " MyBase.New(){0}" +
2758 "End Structure{0}", NewLine), code);
2762 public override void BaseConstructorSingleArg ()
2764 string code = GenerateBaseConstructor (false, Options);
2765 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2766 "Public Structure Test1{0}" +
2768 " Protected Sub New(ByVal value1 As Object, ByRef value2 As Integer){0}" +
2769 " MyBase.New(value1){0}" +
2771 "End Structure{0}", NewLine), code);
2775 public override void BaseConstructorMultipleArgs ()
2777 string code = GenerateBaseConstructor (true, Options);
2778 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2779 "Public Structure Test1{0}" +
2781 " Protected Sub New(ByVal value1 As Object, ByRef value2 As Integer){0}" +
2782 " MyBase.New(value1, value2){0}" +
2784 "End Structure{0}", NewLine), code);
2788 public override void ChainedConstructorSingleArg ()
2790 string code = GenerateChainedConstructor (false, Options);
2791 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2792 "Public Structure Test1{0}" +
2794 " Public Sub New(ByVal value1 As Object, ByRef value2 As Integer){0}" +
2795 " Me.New(value1){0}" +
2797 "End Structure{0}", NewLine), code);
2801 public override void ChainedConstructorMultipleArgs ()
2803 string code = GenerateChainedConstructor (true, Options);
2804 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2805 "Public Structure Test1{0}" +
2807 " Public Sub New(ByVal value1 As Object, ByRef value2 As Integer){0}" +
2808 " Me.New(value1, value2){0}" +
2810 "End Structure{0}", NewLine), code);
2814 public override void TypeConstructorTest ()
2816 string code = GenerateTypeConstructor (Options);
2817 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2818 "Public Structure Test1{0}" +
2824 " Shared Sub New(){0}" +
2826 "End Structure{0}", NewLine), code);
2830 public override void EntryPointMethodTest ()
2832 string code = GenerateEntryPointMethod (Options);
2833 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2834 "Public Structure Test1{0}" +
2839 " Public Shared Sub Main(){0}" +
2840 " Dim x As Test.InnerType{0}" +
2842 "End Structure{0}", NewLine), code);
2847 public class CodeGeneratorFromTypeTest_Enum : CodeGeneratorFromTypeTestBase
2849 private CodeTypeDeclaration _typeDeclaration;
2850 private ICodeGenerator _codeGenerator;
2852 protected override ICodeGenerator CodeGenerator
2854 get { return _codeGenerator; }
2857 protected override CodeTypeDeclaration TypeDeclaration
2859 get { return _typeDeclaration; }
2863 public override void SetUp ()
2866 _typeDeclaration = new CodeTypeDeclaration ();
2867 _typeDeclaration.IsEnum = true;
2869 CodeDomProvider provider = new VBCodeProvider ();
2870 _codeGenerator = provider.CreateGenerator ();
2874 public override void DefaultTypeTest ()
2876 string code = GenerateDefaultType (Options);
2877 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2879 "End Enum{0}", NewLine), code);
2883 [ExpectedException (typeof (NullReferenceException))]
2884 public override void NullTypeTest ()
2886 GenerateNullType (Options);
2890 public override void SimpleTypeTest ()
2892 string code = GenerateSimpleType (Options);
2893 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2894 "Public Enum Test1{0}" +
2895 "End Enum{0}", NewLine), code);
2899 public override void DerivedTypeTest ()
2901 string code = GenerateDerivedType (Options);
2902 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2904 "Friend Enum Test1 As Integer{0}" +
2906 "Enum Test1 As Integer{0}" +
2908 "End Enum{0}", NewLine), code);
2912 public override void AttributesAndTypeTest ()
2914 string code = GenerateAttributesAndType (Options);
2915 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2918 "Public Enum Test1{0}" +
2919 "End Enum{0}", NewLine), code);
2923 public override void EventMembersTypeTest1 ()
2925 string code = GenerateEventMembersType1 (Options);
2926 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2927 "Public Enum Test1{0}" +
2929 "End Enum{0}", NewLine), code);
2933 public override void EventMembersTypeTest2 ()
2935 string code = GenerateEventMembersType2 (Options);
2936 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2937 "Public Enum Test1{0}" +
2939 "End Enum{0}", NewLine), code);
2943 public override void EventImplementationTypes ()
2945 string code = GenerateEventImplementationTypes (Options);
2946 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2947 "Public Enum Test1{0}" +
2949 "End Enum{0}", NewLine), code);
2953 public override void EventPrivateImplementationType ()
2955 string code = GenerateEventPrivateImplementationType (Options);
2956 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2957 "Public Enum Test1{0}" +
2959 "End Enum{0}", NewLine), code);
2963 public override void EventImplementationTypeOrder ()
2965 string code = GenerateEventImplementationTypeOrder (Options);
2966 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2967 "Public Enum Test1{0}" +
2969 "End Enum{0}", NewLine), code);
2973 public override void FieldMembersAttributesTest ()
2975 string code = GenerateFieldMembersAttributes (Options);
2976 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2977 "Public Enum Test1{0}" +
2982 "End Enum{0}", NewLine), code);
2986 public override void FieldMembersTypeTest ()
2988 string code = GenerateFieldMembersType (MemberAttributes.Public, Options);
2989 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2990 "Public Enum Test1{0}" +
2993 "End Enum{0}", NewLine), code);
2997 public override void FieldNewSlotTest ()
2999 string code = GenerateFieldMembersType (MemberAttributes.Assembly |
3000 MemberAttributes.New, Options);
3001 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3002 "Public Enum Test1{0}" +
3005 "End Enum{0}", NewLine), code);
3009 public override void PropertyMembersTypeTest1 ()
3011 string code = GeneratePropertyMembersAttributes (Options);
3012 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3013 "Public Enum Test1{0}" +
3015 "End Enum{0}", NewLine), code);
3019 public override void PropertyMembersTypeTest2 ()
3021 string code = GeneratePropertyMembersType (MemberAttributes.Public,
3022 false, false, Options);
3023 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3024 "Public Enum Test1{0}" +
3026 "End Enum{0}", NewLine), code);
3030 public override void PropertyMembersTypeGetOnly ()
3032 string code = GeneratePropertyMembersType (MemberAttributes.Family,
3033 true, false, Options);
3034 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3035 "Public Enum Test1{0}" +
3037 "End Enum{0}", NewLine), code);
3041 public override void PropertyMembersTypeSetOnly ()
3043 string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
3044 false, true, Options);
3045 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3046 "Public Enum Test1{0}" +
3048 "End Enum{0}", NewLine), code);
3052 public override void PropertyMembersTypeGetSet ()
3054 string code = GeneratePropertyMembersType (MemberAttributes.Family,
3055 true, true, Options);
3056 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3057 "Public Enum Test1{0}" +
3059 "End Enum{0}", NewLine), code);
3063 public override void PropertyMembersTypeFamilyOrAssembly ()
3065 string code = GeneratePropertyMembersType (MemberAttributes.FamilyOrAssembly,
3066 false, false, Options);
3067 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3068 "Public Enum Test1{0}" +
3070 "End Enum{0}", NewLine), code);
3074 public override void PropertyMembersTypeAssembly ()
3076 string code = GeneratePropertyMembersType (MemberAttributes.Assembly,
3077 false, false, Options);
3078 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3079 "Public Enum Test1{0}" +
3081 "End Enum{0}", NewLine), code);
3085 public override void PropertyParametersTest ()
3087 string code = GeneratePropertyParameters (Options);
3088 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3089 "Public Enum Test1{0}" +
3091 "End Enum{0}", NewLine), code);
3095 public override void PropertyIndexerTest1 ()
3097 string code = GeneratePropertyIndexer (MemberAttributes.Public,
3098 false, false, true, Options);
3099 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3100 "Public Enum Test1{0}" +
3102 "End Enum{0}", NewLine), code);
3106 public override void PropertyIndexerTest2 ()
3108 string code = GeneratePropertyIndexer (MemberAttributes.Public,
3109 false, false, false, Options);
3110 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3111 "Public Enum Test1{0}" +
3113 "End Enum{0}", NewLine), code);
3117 public override void PropertyIndexerGetOnly ()
3119 string code = GeneratePropertyIndexer (MemberAttributes.Family,
3120 true, false, true, Options);
3121 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3122 "Public Enum Test1{0}" +
3124 "End Enum{0}", NewLine), code);
3128 public override void PropertyIndexerSetOnly ()
3130 string code = GeneratePropertyIndexer (MemberAttributes.Family,
3131 false, true, true, Options);
3132 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3133 "Public Enum Test1{0}" +
3135 "End Enum{0}", NewLine), code);
3139 public override void PropertyImplementationTypes ()
3141 string code = GeneratePropertyImplementationTypes (Options);
3142 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3143 "Public Enum Test1{0}" +
3145 "End Enum{0}", NewLine), code);
3149 public override void PropertyOverloadsTest1 ()
3151 string code = GeneratePropertyOverloads1 (Options);
3152 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3153 "Public Enum Test1{0}" +
3155 "End Enum{0}", NewLine), code);
3159 public override void PropertyOverloadsTest2 ()
3161 string code = GeneratePropertyOverloads2 (Options);
3162 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3163 "Public Enum Test1{0}" +
3166 "End Enum{0}", NewLine), code);
3170 public override void PropertyOverloadsTest3 ()
3172 string code = GeneratePropertyOverloads3 (Options);
3173 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3174 "Public Enum Test1{0}" +
3177 "End Enum{0}", NewLine), code);
3181 public override void PropertyPrivateImplementationType ()
3183 string code = GeneratePropertyPrivateImplementationType (Options);
3184 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3185 "Public Enum Test1{0}" +
3187 "End Enum{0}", NewLine), code);
3191 public override void PropertyImplementationTypeOrder ()
3193 string code = GeneratePropertyImplementationTypeOrder (Options);
3194 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3195 "Public Enum Test1{0}" +
3197 "End Enum{0}", NewLine), code);
3201 public override void PropertyNewSlotTest ()
3203 string code = GeneratePropertyMembersType (MemberAttributes.Private |
3204 MemberAttributes.New, true, true, Options);
3205 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3206 "Public Enum Test1{0}" +
3208 "End Enum{0}", NewLine), code);
3212 public override void MethodMembersTypeTest1 ()
3214 string code = GenerateMethodMembersType1 (Options);
3215 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3216 "Public Enum Test1{0}" +
3218 "End Enum{0}", NewLine), code);
3222 public override void MethodMembersTypeTest2 ()
3224 string code = GenerateMethodMembersType2 (Options);
3225 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3226 "Public Enum Test1{0}" +
3228 "End Enum{0}", NewLine), code);
3232 public override void MethodMembersTypeTest3 ()
3234 string code = GenerateMethodMembersType3 (Options);
3235 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3236 "Public Enum Test1{0}" +
3238 "End Enum{0}", NewLine), code);
3242 public override void MethodImplementationTypes ()
3244 string code = GenerateMethodImplementationTypes (Options);
3245 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3246 "Public Enum Test1{0}" +
3248 "End Enum{0}", NewLine), code);
3252 public override void MethodOverloadsTest1 ()
3254 string code = GenerateMethodOverloads1 (Options);
3255 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3256 "Public Enum Test1{0}" +
3258 "End Enum{0}", NewLine), code);
3262 public override void MethodOverloadsTest2 ()
3264 string code = GenerateMethodOverloads2 (Options);
3265 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3266 "Public Enum Test1{0}" +
3269 "End Enum{0}", NewLine), code);
3273 public override void MethodOverloadsTest3 ()
3275 string code = GenerateMethodOverloads3 (Options);
3276 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3277 "Public Enum Test1{0}" +
3280 "End Enum{0}", NewLine), code);
3284 public override void MethodPrivateImplementationType ()
3286 string code = GenerateMethodPrivateImplementationType (Options);
3287 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3288 "Public Enum Test1{0}" +
3290 "End Enum{0}", NewLine), code);
3294 public override void MethodImplementationTypeOrder ()
3296 string code = GenerateMethodImplementationTypeOrder (Options);
3297 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3298 "Public Enum Test1{0}" +
3300 "End Enum{0}", NewLine), code);
3304 public override void MethodReturnTypeAttributes ()
3306 string code = GenerateMethodReturnTypeAttributes (Options);
3307 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3308 "Public Enum Test1{0}" +
3310 "End Enum{0}", NewLine), code);
3314 public override void MethodNewSlotTest ()
3316 string code = GenerateMethodNewSlot (Options);
3317 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3318 "Public Enum Test1{0}" +
3320 "End Enum{0}", NewLine), code);
3324 public override void ConstructorAttributesTest ()
3326 string code = GenerateConstructorAttributes (Options);
3327 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3328 "Public Enum Test1{0}" +
3330 "End Enum{0}", NewLine), code);
3334 public override void ConstructorParametersTest ()
3336 string code = GenerateConstructorParameters (Options);
3337 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3338 "Public Enum Test1{0}" +
3340 "End Enum{0}", NewLine), code);
3344 public override void ConstructorParameterAttributesTest ()
3346 string code = GenerateConstructorParameterAttributes (Options);
3347 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3348 "Public Enum Test1{0}" +
3350 "End Enum{0}", NewLine), code);
3354 public override void BaseConstructorSingleArg ()
3356 string code = GenerateBaseConstructor (false, Options);
3357 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3358 "Public Enum Test1{0}" +
3360 "End Enum{0}", NewLine), code);
3364 public override void BaseConstructorMultipleArgs ()
3366 string code = GenerateBaseConstructor (true, Options);
3367 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3368 "Public Enum Test1{0}" +
3370 "End Enum{0}", NewLine), code);
3374 public override void ChainedConstructorSingleArg ()
3376 string code = GenerateChainedConstructor (false, Options);
3377 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3378 "Public Enum Test1{0}" +
3380 "End Enum{0}", NewLine), code);
3384 public override void ChainedConstructorMultipleArgs ()
3386 string code = GenerateChainedConstructor (true, Options);
3387 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3388 "Public Enum Test1{0}" +
3390 "End Enum{0}", NewLine), code);
3394 public override void TypeConstructorTest ()
3396 string code = GenerateTypeConstructor (Options);
3397 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3398 "Public Enum Test1{0}" +
3400 "End Enum{0}", NewLine), code);
3404 public override void EntryPointMethodTest ()
3406 string code = GenerateEntryPointMethod (Options);
3407 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
3408 "Public Enum Test1{0}" +
3413 " Public Shared Sub Main(){0}" +
3414 " Dim x As Test.InnerType{0}" +
3416 "End Enum{0}", NewLine), code);