* VBCodeGenerator.cs: Fixed generated code for abstract properties.
[mono.git] / mcs / class / System / Test / System.CodeDom / CodeLabeledStatementTest.cs
1 //
2 // CodeLabeledStatementTest.cs
3 //      - Unit tests for System.CodeDom.CodeLabeledStatement
4 //
5 // Author:
6 //      Gert Driesen  <drieseng@users.sourceforge.net>
7 //
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 // 
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 // 
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30 using NUnit.Framework;
31
32 using System;
33 using System.CodeDom;
34 using System.Collections.Specialized;
35
36 namespace MonoTests.System.CodeDom
37 {
38         [TestFixture]
39         public class CodeLabeledStatementTest
40         {
41                 [Test]
42                 public void Constructor0 ()
43                 {
44                         CodeLabeledStatement cls = new CodeLabeledStatement ();
45                         Assert.IsNull (cls.LinePragma, "#1");
46
47                         Assert.IsNotNull (cls.Label, "#2");
48                         Assert.AreEqual (string.Empty, cls.Label, "#3");
49
50 #if NET_2_0
51                         Assert.IsNotNull (cls.StartDirectives, "#4");
52                         Assert.AreEqual (0, cls.StartDirectives.Count, "#5");
53
54                         Assert.IsNotNull (cls.EndDirectives, "#6");
55                         Assert.AreEqual (0, cls.EndDirectives.Count, "#7");
56 #endif
57
58                         Assert.IsNotNull (cls.UserData, "#8");
59                         Assert.AreEqual (typeof(ListDictionary), cls.UserData.GetType (), "#9");
60                         Assert.AreEqual (0, cls.UserData.Count, "#10");
61                         
62                         string label = "mono";
63                         cls.Label = label;
64                         Assert.IsNotNull (cls.Label, "#11");
65                         Assert.AreSame (label, cls.Label, "#12");
66
67                         cls.Label = null;
68                         Assert.IsNotNull (cls.Label, "#13");
69                         Assert.AreEqual (string.Empty, cls.Label, "#14");
70
71                         CodeLinePragma clp = new CodeLinePragma ("mono", 10);
72                         cls.LinePragma = clp;
73                         Assert.IsNotNull (cls.LinePragma, "#15");
74                         Assert.AreSame (clp, cls.LinePragma, "#16");
75
76                         cls.LinePragma = null;
77                         Assert.IsNull (cls.LinePragma, "#17");
78
79                         Assert.IsNull (cls.Statement, "#18");
80
81                         CodeStatement stmt = new CodeStatement ();
82                         cls.Statement = stmt;
83                         Assert.IsNotNull (cls.Statement, "#19");
84                         Assert.AreSame (stmt, cls.Statement);
85                 }
86
87                 [Test]
88                 public void Constructor1 ()
89                 {
90                         string label = "mono";
91
92                         CodeLabeledStatement cls = new CodeLabeledStatement (label);
93                         Assert.IsNull (cls.LinePragma, "#1");
94
95                         Assert.IsNotNull (cls.Label, "#2");
96                         Assert.AreSame (label, cls.Label, "#3");
97
98 #if NET_2_0
99                         Assert.IsNotNull (cls.StartDirectives, "#4");
100                         Assert.AreEqual (0, cls.StartDirectives.Count, "#5");
101
102                         Assert.IsNotNull (cls.EndDirectives, "#6");
103                         Assert.AreEqual (0, cls.EndDirectives.Count, "#7");
104 #endif
105
106                         Assert.IsNotNull (cls.UserData, "#8");
107                         Assert.AreEqual (typeof(ListDictionary), cls.UserData.GetType (), "#9");
108                         Assert.AreEqual (0, cls.UserData.Count, "#10");
109
110                         Assert.IsNull (cls.Statement, "#11");
111                         
112                         cls = new CodeLabeledStatement ((string) null);
113                         Assert.IsNotNull (cls.Label, "#12");
114                         Assert.AreEqual (string.Empty, cls.Label, "#13");
115                 }
116
117                 [Test]
118                 public void Constructor2 () {
119                         string label = "mono";
120                         CodeStatement stmt = new CodeStatement ();
121
122                         CodeLabeledStatement cls = new CodeLabeledStatement (label, stmt);
123                         Assert.IsNull (cls.LinePragma, "#1");
124
125                         Assert.IsNotNull (cls.Label, "#2");
126                         Assert.AreSame (label, cls.Label, "#3");
127
128 #if NET_2_0
129                         Assert.IsNotNull (cls.StartDirectives, "#4");
130                         Assert.AreEqual (0, cls.StartDirectives.Count, "#5");
131
132                         Assert.IsNotNull (cls.EndDirectives, "#6");
133                         Assert.AreEqual (0, cls.EndDirectives.Count, "#7");
134 #endif
135
136                         Assert.IsNotNull (cls.UserData, "#8");
137                         Assert.AreEqual (typeof(ListDictionary), cls.UserData.GetType (), "#9");
138                         Assert.AreEqual (0, cls.UserData.Count, "#10");
139
140                         Assert.IsNotNull (cls.Statement, "#11");
141                         Assert.AreSame (stmt, cls.Statement, "#12");
142                         
143                         cls = new CodeLabeledStatement ((string) null, (CodeStatement) null);
144                         Assert.IsNotNull (cls.Label, "#13");
145                         Assert.AreEqual (string.Empty, cls.Label, "#14");
146                         Assert.IsNull (cls.Statement, "#15");
147                 }
148         }
149 }