Merge pull request #2396 from akoeplinger/flaky-osx-socket-test
[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                         Assert.IsNotNull (cls.StartDirectives, "#4");
51                         Assert.AreEqual (0, cls.StartDirectives.Count, "#5");
52
53                         Assert.IsNotNull (cls.EndDirectives, "#6");
54                         Assert.AreEqual (0, cls.EndDirectives.Count, "#7");
55
56                         Assert.IsNotNull (cls.UserData, "#8");
57                         Assert.AreEqual (typeof(ListDictionary), cls.UserData.GetType (), "#9");
58                         Assert.AreEqual (0, cls.UserData.Count, "#10");
59                         
60                         string label = "mono";
61                         cls.Label = label;
62                         Assert.IsNotNull (cls.Label, "#11");
63                         Assert.AreSame (label, cls.Label, "#12");
64
65                         cls.Label = null;
66                         Assert.IsNotNull (cls.Label, "#13");
67                         Assert.AreEqual (string.Empty, cls.Label, "#14");
68
69                         CodeLinePragma clp = new CodeLinePragma ("mono", 10);
70                         cls.LinePragma = clp;
71                         Assert.IsNotNull (cls.LinePragma, "#15");
72                         Assert.AreSame (clp, cls.LinePragma, "#16");
73
74                         cls.LinePragma = null;
75                         Assert.IsNull (cls.LinePragma, "#17");
76
77                         Assert.IsNull (cls.Statement, "#18");
78
79                         CodeStatement stmt = new CodeStatement ();
80                         cls.Statement = stmt;
81                         Assert.IsNotNull (cls.Statement, "#19");
82                         Assert.AreSame (stmt, cls.Statement);
83                 }
84
85                 [Test]
86                 public void Constructor1 ()
87                 {
88                         string label = "mono";
89
90                         CodeLabeledStatement cls = new CodeLabeledStatement (label);
91                         Assert.IsNull (cls.LinePragma, "#1");
92
93                         Assert.IsNotNull (cls.Label, "#2");
94                         Assert.AreSame (label, cls.Label, "#3");
95
96                         Assert.IsNotNull (cls.StartDirectives, "#4");
97                         Assert.AreEqual (0, cls.StartDirectives.Count, "#5");
98
99                         Assert.IsNotNull (cls.EndDirectives, "#6");
100                         Assert.AreEqual (0, cls.EndDirectives.Count, "#7");
101
102                         Assert.IsNotNull (cls.UserData, "#8");
103                         Assert.AreEqual (typeof(ListDictionary), cls.UserData.GetType (), "#9");
104                         Assert.AreEqual (0, cls.UserData.Count, "#10");
105
106                         Assert.IsNull (cls.Statement, "#11");
107                         
108                         cls = new CodeLabeledStatement ((string) null);
109                         Assert.IsNotNull (cls.Label, "#12");
110                         Assert.AreEqual (string.Empty, cls.Label, "#13");
111                 }
112
113                 [Test]
114                 public void Constructor2 () {
115                         string label = "mono";
116                         CodeStatement stmt = new CodeStatement ();
117
118                         CodeLabeledStatement cls = new CodeLabeledStatement (label, stmt);
119                         Assert.IsNull (cls.LinePragma, "#1");
120
121                         Assert.IsNotNull (cls.Label, "#2");
122                         Assert.AreSame (label, cls.Label, "#3");
123
124                         Assert.IsNotNull (cls.StartDirectives, "#4");
125                         Assert.AreEqual (0, cls.StartDirectives.Count, "#5");
126
127                         Assert.IsNotNull (cls.EndDirectives, "#6");
128                         Assert.AreEqual (0, cls.EndDirectives.Count, "#7");
129
130                         Assert.IsNotNull (cls.UserData, "#8");
131                         Assert.AreEqual (typeof(ListDictionary), cls.UserData.GetType (), "#9");
132                         Assert.AreEqual (0, cls.UserData.Count, "#10");
133
134                         Assert.IsNotNull (cls.Statement, "#11");
135                         Assert.AreSame (stmt, cls.Statement, "#12");
136                         
137                         cls = new CodeLabeledStatement ((string) null, (CodeStatement) null);
138                         Assert.IsNotNull (cls.Label, "#13");
139                         Assert.AreEqual (string.Empty, cls.Label, "#14");
140                         Assert.IsNull (cls.Statement, "#15");
141                 }
142         }
143 }