2 // CodeLabeledStatementTest.cs
3 // - Unit tests for System.CodeDom.CodeLabeledStatement
6 // Gert Driesen <drieseng@users.sourceforge.net>
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
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:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
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.
30 using NUnit.Framework;
34 using System.Collections.Specialized;
36 namespace MonoTests.System.CodeDom
39 public class CodeLabeledStatementTest
42 public void Constructor0 ()
44 CodeLabeledStatement cls = new CodeLabeledStatement ();
45 Assert.IsNull (cls.LinePragma, "#1");
47 Assert.IsNotNull (cls.Label, "#2");
48 Assert.AreEqual (string.Empty, cls.Label, "#3");
50 Assert.IsNotNull (cls.StartDirectives, "#4");
51 Assert.AreEqual (0, cls.StartDirectives.Count, "#5");
53 Assert.IsNotNull (cls.EndDirectives, "#6");
54 Assert.AreEqual (0, cls.EndDirectives.Count, "#7");
56 Assert.IsNotNull (cls.UserData, "#8");
57 Assert.AreEqual (typeof(ListDictionary), cls.UserData.GetType (), "#9");
58 Assert.AreEqual (0, cls.UserData.Count, "#10");
60 string label = "mono";
62 Assert.IsNotNull (cls.Label, "#11");
63 Assert.AreSame (label, cls.Label, "#12");
66 Assert.IsNotNull (cls.Label, "#13");
67 Assert.AreEqual (string.Empty, cls.Label, "#14");
69 CodeLinePragma clp = new CodeLinePragma ("mono", 10);
71 Assert.IsNotNull (cls.LinePragma, "#15");
72 Assert.AreSame (clp, cls.LinePragma, "#16");
74 cls.LinePragma = null;
75 Assert.IsNull (cls.LinePragma, "#17");
77 Assert.IsNull (cls.Statement, "#18");
79 CodeStatement stmt = new CodeStatement ();
81 Assert.IsNotNull (cls.Statement, "#19");
82 Assert.AreSame (stmt, cls.Statement);
86 public void Constructor1 ()
88 string label = "mono";
90 CodeLabeledStatement cls = new CodeLabeledStatement (label);
91 Assert.IsNull (cls.LinePragma, "#1");
93 Assert.IsNotNull (cls.Label, "#2");
94 Assert.AreSame (label, cls.Label, "#3");
96 Assert.IsNotNull (cls.StartDirectives, "#4");
97 Assert.AreEqual (0, cls.StartDirectives.Count, "#5");
99 Assert.IsNotNull (cls.EndDirectives, "#6");
100 Assert.AreEqual (0, cls.EndDirectives.Count, "#7");
102 Assert.IsNotNull (cls.UserData, "#8");
103 Assert.AreEqual (typeof(ListDictionary), cls.UserData.GetType (), "#9");
104 Assert.AreEqual (0, cls.UserData.Count, "#10");
106 Assert.IsNull (cls.Statement, "#11");
108 cls = new CodeLabeledStatement ((string) null);
109 Assert.IsNotNull (cls.Label, "#12");
110 Assert.AreEqual (string.Empty, cls.Label, "#13");
114 public void Constructor2 () {
115 string label = "mono";
116 CodeStatement stmt = new CodeStatement ();
118 CodeLabeledStatement cls = new CodeLabeledStatement (label, stmt);
119 Assert.IsNull (cls.LinePragma, "#1");
121 Assert.IsNotNull (cls.Label, "#2");
122 Assert.AreSame (label, cls.Label, "#3");
124 Assert.IsNotNull (cls.StartDirectives, "#4");
125 Assert.AreEqual (0, cls.StartDirectives.Count, "#5");
127 Assert.IsNotNull (cls.EndDirectives, "#6");
128 Assert.AreEqual (0, cls.EndDirectives.Count, "#7");
130 Assert.IsNotNull (cls.UserData, "#8");
131 Assert.AreEqual (typeof(ListDictionary), cls.UserData.GetType (), "#9");
132 Assert.AreEqual (0, cls.UserData.Count, "#10");
134 Assert.IsNotNull (cls.Statement, "#11");
135 Assert.AreSame (stmt, cls.Statement, "#12");
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");