Kaynağa Gözat

* CodeArgumentReferenceExpressionTest.cs: Added test for default ctor
and default value of ParameterName.
* CodeArrayCreateExpressionTest.cs: Added test for default ctor and
default value of CreateType.
* CodeAttachEventStatementTest.cs: Added test for default ctor and
default value of Event.
* CodeAttributeArgumentTest.cs: Added test for default ctor and default
value of Name.
* CodeAttributeDeclarationTest.cs: Added test for default ctor and
default value of Name.
* System_test.dll.sources: Added CodeArgumentReferenceExceptionTest.cs,
CodeArrayCreateExpressionTest.cs, CodeAttachEventStatementTest.cs,
CodeAttributeArgumentTest.cs, CodeAttributeDeclarationTest.cs.
* CodeArgumentReferenceExpression.cs: If ParameterName is null, return
string.Empty.
* CodeArrayCreateExpression.cs: Implement default value in CreateType
property.
* CodeAttachEventStatement.cs: Implement default value in Event
property.
* CodeAttributeArgument.cs: Implement default value in Name property.
* CodeAttributeDeclaration.cs: Implement default value in Name
property.

svn path=/trunk/mcs/; revision=52147

Gert Driesen 20 yıl önce
ebeveyn
işleme
cdfa103b25

+ 6 - 0
mcs/class/System/ChangeLog

@@ -1,3 +1,9 @@
+2005-10-24  Gert Driesen  <[email protected]>
+
+	* System_test.dll.sources: Added CodeArgumentReferenceExceptionTest.cs,
+	CodeArrayCreateExpressionTest.cs, CodeAttachEventStatementTest.cs,
+	CodeAttributeArgumentTest.cs, CodeAttributeDeclarationTest.cs.
+
 2005-10-18  Gert Driesen  <[email protected]>
 
 	* System_test.dll.sources: Added HttpWebRequestElementTest.cs

+ 12 - 0
mcs/class/System/System.CodeDom/ChangeLog

@@ -1,3 +1,15 @@
+2005-10-24  Gert Driesen  <[email protected]>
+
+	* CodeArgumentReferenceExpression.cs: If ParameterName is null, return
+	string.Empty.
+	* CodeArrayCreateExpression.cs: Implement default value in CreateType
+	property.
+	* CodeAttachEventStatement.cs: Implement default value in Event
+	property.
+	* CodeAttributeArgument.cs: Implement default value in Name property.
+	* CodeAttributeDeclaration.cs: Implement default value in Name
+	property.
+
 2005-10-24  Gert Driesen  <[email protected]>
 
 	* CodeTypeReference.cs: Ignore ArrayElementType for determining

+ 3 - 1
mcs/class/System/System.CodeDom/CodeArgumentReferenceExpression.cs

@@ -44,7 +44,6 @@ namespace System.CodeDom {
 		//
 		public CodeArgumentReferenceExpression()
 		{
-			parameterName = String.Empty;
 		}
 
 		public CodeArgumentReferenceExpression( string name )
@@ -57,6 +56,9 @@ namespace System.CodeDom {
 		//
 		public string ParameterName {
 			get {
+				if (parameterName == null) {
+					return string.Empty;
+				}
 				return parameterName;
 			}
 			set {

+ 3 - 2
mcs/class/System/System.CodeDom/CodeArrayCreateExpression.cs

@@ -48,10 +48,8 @@ namespace System.CodeDom {
 		//
 		public CodeArrayCreateExpression ()
 		{
-			createType = new CodeTypeReference (typeof (void));
 		}
 
-
 		public CodeArrayCreateExpression (CodeTypeReference createType, 
 						  CodeExpression size )
 		{
@@ -122,6 +120,9 @@ namespace System.CodeDom {
 		//
 		public CodeTypeReference CreateType {
 			get {
+				if (createType == null) {
+					createType = new CodeTypeReference (typeof (void));
+				}
 				return createType;
 			}
 			set {

+ 4 - 4
mcs/class/System/System.CodeDom/CodeAttachEventStatement.cs

@@ -46,7 +46,6 @@ namespace System.CodeDom
 		//
 		public CodeAttachEventStatement ()
 		{
-			eventRef = new CodeEventReferenceExpression (null, String.Empty);
 		}
 
 		public CodeAttachEventStatement (CodeEventReferenceExpression eventRef,
@@ -60,16 +59,17 @@ namespace System.CodeDom
 						 string eventName, 
 						 CodeExpression listener)
 		{
-			this.eventRef = new CodeEventReferenceExpression( targetObject,
-									  eventName );
 			this.listener = listener;
 		}
-								  
+
 		//
 		// Properties
 		//
 		public CodeEventReferenceExpression Event {
 			get {
+				if (eventRef == null) {
+					eventRef = new CodeEventReferenceExpression ();
+				}
 				return eventRef;
 			}
 			set {

+ 3 - 2
mcs/class/System/System.CodeDom/CodeAttributeArgument.cs

@@ -44,12 +44,10 @@ namespace System.CodeDom
 		//
 		public CodeAttributeArgument ()
 		{
-			name = String.Empty;
 		}
 
 		public CodeAttributeArgument (CodeExpression value)
 		{
-			name = String.Empty;
 			this.value = value;
 		}
 
@@ -64,6 +62,9 @@ namespace System.CodeDom
 		//
 		public string Name {
 			get {
+				if (name == null) {
+					return string.Empty;
+				}
 				return name;
 			}
 			set {

+ 11 - 5
mcs/class/System/System.CodeDom/CodeAttributeDeclaration.cs

@@ -42,18 +42,17 @@ namespace System.CodeDom
 		private CodeAttributeArgumentCollection arguments;
 #if NET_2_0
 		private CodeTypeReference attribute;
-#endif		
+#endif
+
 		//
 		// Constructors
 		//
 		public CodeAttributeDeclaration ()
 		{
-			name = String.Empty;
 		}
 
 		public CodeAttributeDeclaration (string name)
 		{
-			this.name = name;
 		}
 
 		public CodeAttributeDeclaration (string name, params CodeAttributeArgument [] arguments)
@@ -61,6 +60,7 @@ namespace System.CodeDom
 			this.name = name;
 			Arguments.AddRange (arguments);
 		}
+
 #if NET_2_0
 		public CodeAttributeDeclaration (CodeTypeReference attributeType)
 		{
@@ -73,13 +73,15 @@ namespace System.CodeDom
 			Arguments.AddRange (arguments);
 		}
 #endif
+
 		//
 		// Properties
 		//
 		public CodeAttributeArgumentCollection Arguments {
 			get {
-				if ( arguments == null )
-					arguments = new CodeAttributeArgumentCollection();
+				if (arguments == null) {
+					arguments = new CodeAttributeArgumentCollection ();
+				}
 
 				return arguments;
 			}
@@ -87,12 +89,16 @@ namespace System.CodeDom
 
 		public string Name {
 			get {
+				if (name == null) {
+					return string.Empty;
+				}
 				return name;
 			}
 			set {
 				name = value;
 			}
 		}
+
 #if NET_2_0
 		public CodeTypeReference AttributeType {
 			get { return attribute; }

+ 5 - 0
mcs/class/System/System_test.dll.sources

@@ -17,6 +17,11 @@ System/UriBuilderTest.cs
 System/UriTest.cs
 System/UriTest2.cs
 System/UriTypeConverterTest.cs
+System.CodeDom/CodeArgumentReferenceExpressionTest.cs
+System.CodeDom/CodeArrayCreateExpressionTest.cs
+System.CodeDom/CodeAttachEventStatementTest.cs
+System.CodeDom/CodeAttributeArgumentTest.cs
+System.CodeDom/CodeAttributeDeclarationTest.cs
 System.CodeDom/CodeMemberFieldTest.cs
 System.CodeDom/CodeMemberPropertyTest.cs
 System.CodeDom/CodeTypeDelegateTest.cs

+ 13 - 0
mcs/class/System/Test/System.CodeDom/ChangeLog

@@ -1,3 +1,16 @@
+2005-10-24  Gert Driesen  <[email protected]>
+
+	* CodeArgumentReferenceExpressionTest.cs: Added test for default ctor
+	and default value of ParameterName.
+	* CodeArrayCreateExpressionTest.cs: Added test for default ctor and
+	default value of CreateType.
+	* CodeAttachEventStatementTest.cs: Added test for default ctor and
+	default value of Event.
+	* CodeAttributeArgumentTest.cs: Added test for default ctor and 
+	default value of Name.
+	* CodeAttributeDeclarationTest.cs: Added test for default ctor and
+	default value of Name.
+
 2005-10-24  Gert Driesen  <[email protected]>
 
 	* CodeTypeReferenceTest.cs: Enabled test case for bug #76535. Added

+ 56 - 0
mcs/class/System/Test/System.CodeDom/CodeArgumentReferenceExpressionTest.cs

@@ -0,0 +1,56 @@
+//
+// CodeArgumentReferenceExpressionTest.cs
+//	- Unit tests for System.CodeDom.CodeArgumentReferenceExpression
+//
+// Author:
+//	Gert Driesen  <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.CodeDom;
+
+namespace MonoCasTests.System.CodeDom {
+	[TestFixture]
+	public class CodeArgumentReferenceExpressionTest {
+		[Test]
+		public void DefaultConstructor ()
+		{
+			CodeArgumentReferenceExpression care = new CodeArgumentReferenceExpression ();
+			Assert.AreEqual (string.Empty, care.ParameterName, "#1");
+			care.ParameterName = "mono";
+			Assert.AreEqual ("mono", care.ParameterName, "#2");
+		}
+
+		[Test]
+		public void NullParameter ()
+		{
+			CodeArgumentReferenceExpression care = new CodeArgumentReferenceExpression ((string) null);
+			Assert.AreEqual (string.Empty, care.ParameterName, "#1");
+			care.ParameterName = null;
+			Assert.AreEqual (string.Empty, care.ParameterName, "#2");
+		}
+	}
+}

+ 60 - 0
mcs/class/System/Test/System.CodeDom/CodeArrayCreateExpressionTest.cs

@@ -0,0 +1,60 @@
+//
+// CodeArrayCreateExpressionTest.cs
+//	- Unit tests for System.CodeDom.CodeArrayCreateExpression
+//
+// Author:
+//	Gert Driesen  <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.CodeDom;
+
+namespace MonoCasTests.System.CodeDom
+{
+	[TestFixture]
+	public class CodeArrayCreateExpressionTest
+	{
+		[Test]
+		public void DefaultConstructor ()
+		{
+			CodeArrayCreateExpression cace = new CodeArrayCreateExpression ();
+			Assert.IsNotNull (cace.CreateType, "#1");
+			Assert.AreEqual (typeof (void).FullName, cace.CreateType.BaseType, "#2");
+		}
+
+		[Test]
+		public void NullCreateType ()
+		{
+			CodeArrayCreateExpression cace = new CodeArrayCreateExpression ((CodeTypeReference) null, 0);
+			Assert.IsNotNull (cace.CreateType, "#1");
+			Assert.AreEqual (typeof (void).FullName, cace.CreateType.BaseType, "#2");
+
+			cace.CreateType = null;
+			Assert.IsNotNull (cace.CreateType, "#3");
+			Assert.AreEqual (typeof (void).FullName, cace.CreateType.BaseType, "#4");
+		}
+	}
+}

+ 65 - 0
mcs/class/System/Test/System.CodeDom/CodeAttachEventStatementTest.cs

@@ -0,0 +1,65 @@
+//
+// CodeAttachEventStatementTest.cs
+//	- Unit tests for System.CodeDom.CodeAttachEventStatement 
+//
+// Author:
+//	Gert Driesen  <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.CodeDom;
+
+namespace MonoCasTests.System.CodeDom
+{
+	[TestFixture]
+	public class CodeAttachEventStatementTest
+	{
+		[Test]
+		public void DefaultConstructor ()
+		{
+			CodeAttachEventStatement caes = new CodeAttachEventStatement ();
+			Assert.IsNotNull (caes.Event, "#1");
+			Assert.IsNull (caes.Listener, "#2");
+			Assert.AreEqual (string.Empty, caes.Event.EventName, "#3");
+			Assert.IsNull (caes.Event.TargetObject, "#4");
+		}
+
+		[Test]
+		public void NullEventReference ()
+		{
+			CodeAttachEventStatement caes = new CodeAttachEventStatement ((CodeEventReferenceExpression) null, (CodeExpression) null);
+			Assert.IsNotNull (caes.Event, "#1");
+			Assert.IsNull (caes.Listener, "#2");
+			Assert.AreEqual (string.Empty, caes.Event.EventName, "#3");
+			Assert.IsNull (caes.Event.TargetObject, "#4");
+
+			caes.Event = null;
+			Assert.IsNotNull (caes.Event, "#5");
+			Assert.AreEqual (string.Empty, caes.Event.EventName, "#6");
+			Assert.IsNull (caes.Event.TargetObject, "#7");
+		}
+	}
+}

+ 62 - 0
mcs/class/System/Test/System.CodeDom/CodeAttributeArgumentTest.cs

@@ -0,0 +1,62 @@
+//
+// CodeAttributeArgumentTest.cs
+//	- Unit tests for System.CodeDom.CodeAttributeArgument
+//
+// Author:
+//	Gert Driesen  <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.CodeDom;
+
+namespace MonoCasTests.System.CodeDom
+{
+	[TestFixture]
+	public class CodeAttributeArgumentTest
+	{
+		[Test]
+		public void DefaultConstructor ()
+		{
+			CodeAttributeArgument caa = new CodeAttributeArgument ();
+			Assert.IsNotNull (caa.Name, "#1");
+			Assert.AreEqual (string.Empty, caa.Name, "#2");
+			Assert.IsNull (caa.Value, "#3");
+		}
+
+		[Test]
+		public void NullName ()
+		{
+			CodeAttributeArgument caa = new CodeAttributeArgument ((string) null, (CodeExpression) null);
+			Assert.IsNotNull (caa.Name, "#1");
+			Assert.AreEqual (string.Empty, caa.Name, "#2");
+			Assert.IsNull (caa.Value, "#3");
+
+			caa.Name = null;
+			Assert.IsNotNull (caa.Name, "#4");
+			Assert.AreEqual (string.Empty, caa.Name, "#5");
+		}
+	}
+}

+ 70 - 0
mcs/class/System/Test/System.CodeDom/CodeAttributeDeclarationTest.cs

@@ -0,0 +1,70 @@
+//
+// CodeAttributeDeclarationTest.cs
+//	- Unit tests for System.CodeDom.CodeAttributeDeclaration
+//
+// Author:
+//	Gert Driesen  <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.CodeDom;
+
+namespace MonoCasTests.System.CodeDom
+{
+	[TestFixture]
+	public class CodeAttributeDeclarationTest
+	{
+		[Test]
+		public void DefaultConstructor ()
+		{
+			CodeAttributeDeclaration cad = new CodeAttributeDeclaration ();
+			Assert.IsNotNull (cad.Name, "#1");
+			Assert.AreEqual (string.Empty, cad.Name, "#2");
+#if NET_2_0
+			Assert.IsNull (cad.AttributeType, "#3");
+#endif
+			Assert.IsNotNull (cad.Arguments, "#4");
+			Assert.AreEqual (0, cad.Arguments.Count, "#5");
+		}
+
+		[Test]
+		public void NullName ()
+		{
+			CodeAttributeDeclaration cad = new CodeAttributeDeclaration ((string) null);
+			Assert.IsNotNull (cad.Name, "#1");
+			Assert.AreEqual (string.Empty, cad.Name, "#2");
+#if NET_2_0
+			Assert.IsNull (cad.AttributeType, "#3");
+#endif
+			Assert.IsNotNull (cad.Arguments, "#4");
+			Assert.AreEqual (0, cad.Arguments.Count, "#5");
+
+			cad.Name = null;
+			Assert.IsNotNull (cad.Name, "#4");
+			Assert.AreEqual (string.Empty, cad.Name, "#5");
+		}
+	}
+}