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");
51 Assert.IsNotNull (cls.StartDirectives, "#4");
52 Assert.AreEqual (0, cls.StartDirectives.Count, "#5");
54 Assert.IsNotNull (cls.EndDirectives, "#6");
55 Assert.AreEqual (0, cls.EndDirectives.Count, "#7");
58 Assert.IsNotNull (cls.UserData, "#8");
59 Assert.AreEqual (typeof(ListDictionary), cls.UserData.GetType (), "#9");
60 Assert.AreEqual (0, cls.UserData.Count, "#10");
62 string label = "mono";
64 Assert.IsNotNull (cls.Label, "#11");
65 Assert.AreSame (label, cls.Label, "#12");
68 Assert.IsNotNull (cls.Label, "#13");
69 Assert.AreEqual (string.Empty, cls.Label, "#14");
71 CodeLinePragma clp = new CodeLinePragma ("mono", 10);
73 Assert.IsNotNull (cls.LinePragma, "#15");
74 Assert.AreSame (clp, cls.LinePragma, "#16");
76 cls.LinePragma = null;
77 Assert.IsNull (cls.LinePragma, "#17");
79 Assert.IsNull (cls.Statement, "#18");
81 CodeStatement stmt = new CodeStatement ();
83 Assert.IsNotNull (cls.Statement, "#19");
84 Assert.AreSame (stmt, cls.Statement);
88 public void Constructor1 ()
90 string label = "mono";
92 CodeLabeledStatement cls = new CodeLabeledStatement (label);
93 Assert.IsNull (cls.LinePragma, "#1");
95 Assert.IsNotNull (cls.Label, "#2");
96 Assert.AreSame (label, cls.Label, "#3");
99 Assert.IsNotNull (cls.StartDirectives, "#4");
100 Assert.AreEqual (0, cls.StartDirectives.Count, "#5");
102 Assert.IsNotNull (cls.EndDirectives, "#6");
103 Assert.AreEqual (0, cls.EndDirectives.Count, "#7");
106 Assert.IsNotNull (cls.UserData, "#8");
107 Assert.AreEqual (typeof(ListDictionary), cls.UserData.GetType (), "#9");
108 Assert.AreEqual (0, cls.UserData.Count, "#10");
110 Assert.IsNull (cls.Statement, "#11");
112 cls = new CodeLabeledStatement ((string) null);
113 Assert.IsNotNull (cls.Label, "#12");
114 Assert.AreEqual (string.Empty, cls.Label, "#13");
118 public void Constructor2 () {
119 string label = "mono";
120 CodeStatement stmt = new CodeStatement ();
122 CodeLabeledStatement cls = new CodeLabeledStatement (label, stmt);
123 Assert.IsNull (cls.LinePragma, "#1");
125 Assert.IsNotNull (cls.Label, "#2");
126 Assert.AreSame (label, cls.Label, "#3");
129 Assert.IsNotNull (cls.StartDirectives, "#4");
130 Assert.AreEqual (0, cls.StartDirectives.Count, "#5");
132 Assert.IsNotNull (cls.EndDirectives, "#6");
133 Assert.AreEqual (0, cls.EndDirectives.Count, "#7");
136 Assert.IsNotNull (cls.UserData, "#8");
137 Assert.AreEqual (typeof(ListDictionary), cls.UserData.GetType (), "#9");
138 Assert.AreEqual (0, cls.UserData.Count, "#10");
140 Assert.IsNotNull (cls.Statement, "#11");
141 Assert.AreSame (stmt, cls.Statement, "#12");
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");