Merge pull request #2396 from akoeplinger/flaky-osx-socket-test
[mono.git] / mcs / class / System / Test / System.CodeDom / CodeAttributeDeclarationTest.cs
1 //
2 // CodeAttributeDeclarationTest.cs
3 //      - Unit tests for System.CodeDom.CodeAttributeDeclaration
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
35 namespace MonoTests.System.CodeDom
36 {
37         [TestFixture]
38         public class CodeAttributeDeclarationTest
39         {
40                 [Test]
41                 public void NullName ()
42                 {
43                         CodeAttributeDeclaration cad = new CodeAttributeDeclaration ((string) null);
44                         Assert.IsNotNull (cad.Name, "#1");
45                         Assert.AreEqual (string.Empty, cad.Name, "#2");
46                         Assert.IsNotNull (cad.AttributeType, "#3");
47                         Assert.AreEqual (typeof(void).FullName, cad.AttributeType.BaseType, "#4");
48                         Assert.IsNotNull (cad.Arguments, "#5");
49                         Assert.AreEqual (0, cad.Arguments.Count, "#6");
50
51                         cad.Name = null;
52                         Assert.IsNotNull (cad.Name, "#7");
53                         Assert.AreEqual (string.Empty, cad.Name, "#8");
54                         Assert.IsNotNull (cad.AttributeType, "#9");
55                         Assert.AreEqual (typeof(void).FullName, cad.AttributeType.BaseType, "#10");
56                 }
57
58                 [Test]
59                 public void Constructor0 ()
60                 {
61                         CodeAttributeDeclaration cad = new CodeAttributeDeclaration ();
62                         Assert.IsNotNull (cad.Name, "#1");
63                         Assert.AreEqual (string.Empty, cad.Name, "#2");
64                         Assert.IsNull (cad.AttributeType, "#3");
65                         Assert.IsNotNull (cad.Arguments, "#4");
66                         Assert.AreEqual (0, cad.Arguments.Count, "#5");
67                 }
68
69                 [Test]
70                 public void Constructor1 ()
71                 {
72                         CodeAttributeDeclaration cad = new CodeAttributeDeclaration ("mono");
73                         Assert.AreEqual (0, cad.Arguments.Count, "#1");
74                         Assert.AreEqual ("mono", cad.Name, "#2");
75                         Assert.IsNotNull (cad.AttributeType, "#3");
76                         Assert.AreEqual ("mono", cad.AttributeType.BaseType, "#4");
77                 }
78
79                 [Test]
80                 public void Constructor2 ()
81                 {
82                         CodeAttributeDeclaration cad = new CodeAttributeDeclaration ("mono", new CodeAttributeArgument ());
83                         Assert.AreEqual (1, cad.Arguments.Count, "#1");
84                         Assert.AreEqual ("mono", cad.Name, "#2");
85                         Assert.IsNotNull (cad.AttributeType, "#3");
86                         Assert.AreEqual ("mono", cad.AttributeType.BaseType, "#4");
87                         cad.Name = null;
88                         Assert.AreEqual (1, cad.Arguments.Count, "#5");
89                         Assert.AreEqual (string.Empty, cad.Name, "#6");
90                         Assert.IsNotNull (cad.AttributeType, "#7");
91                         Assert.AreEqual (typeof(void).FullName, cad.AttributeType.BaseType, "#8");
92                 }
93
94                 [Test]
95                 public void Constructor3 ()
96                 {
97                         CodeAttributeDeclaration cad = new CodeAttributeDeclaration (new CodeTypeReference ("mono"));
98                         Assert.AreEqual (0, cad.Arguments.Count, "#1");
99                         Assert.AreEqual ("mono", cad.Name, "#2");
100                         Assert.IsNotNull (cad.AttributeType, "#3");
101                         Assert.AreEqual ("mono", cad.AttributeType.BaseType, "#4");
102
103                         cad.Name = null;
104                         Assert.AreEqual (0, cad.Arguments.Count, "#5");
105                         Assert.AreEqual (string.Empty, cad.Name, "#6");
106                         Assert.AreEqual (typeof(void).FullName, cad.AttributeType.BaseType, "#7");
107
108                         cad.Name = "mono";
109                         Assert.AreEqual (0, cad.Arguments.Count, "#8");
110                         Assert.AreEqual ("mono", cad.Name, "#9");
111                         Assert.IsNotNull (cad.AttributeType, "#10");
112                         Assert.AreEqual ("mono", cad.AttributeType.BaseType, "#11");
113
114                         cad = new CodeAttributeDeclaration ((CodeTypeReference) null);
115                         Assert.AreEqual (0, cad.Arguments.Count, "#12");
116                         Assert.AreEqual (string.Empty, cad.Name, "#13");
117                         Assert.IsNull (cad.AttributeType, "#14");
118                 }
119
120                 [Test]
121                 public void Constructor4 ()
122                 {
123                         CodeAttributeDeclaration cad = new CodeAttributeDeclaration (new CodeTypeReference ("mono"),
124                                 new CodeAttributeArgument (), new CodeAttributeArgument ());
125                         Assert.AreEqual (2, cad.Arguments.Count, "#1");
126                         Assert.AreEqual ("mono", cad.Name, "#2");
127                         Assert.IsNotNull (cad.AttributeType, "#3");
128                         Assert.AreEqual ("mono", cad.AttributeType.BaseType, "#4");
129
130                         cad.Name = null;
131                         Assert.AreEqual (2, cad.Arguments.Count, "#5");
132                         Assert.AreEqual (string.Empty, cad.Name, "#6");
133                         Assert.AreEqual (typeof(void).FullName, cad.AttributeType.BaseType, "#7");
134
135                         cad.Name = "mono";
136                         Assert.AreEqual (2, cad.Arguments.Count, "#8");
137                         Assert.AreEqual ("mono", cad.Name, "#9");
138                         Assert.IsNotNull (cad.AttributeType, "#10");
139                         Assert.AreEqual ("mono", cad.AttributeType.BaseType, "#11");
140
141                         cad = new CodeAttributeDeclaration ((CodeTypeReference) null,
142                                 new CodeAttributeArgument ());
143                         Assert.AreEqual (1, cad.Arguments.Count, "#12");
144                         Assert.AreEqual (string.Empty, cad.Name, "#13");
145                         Assert.IsNull (cad.AttributeType, "#14");
146                 }
147         }
148 }