Jelajahi Sumber

2005-12-02 Chris Toshok <[email protected]>

	* System.Configuration/ConnectionStringSettingsTest.cs: new tests.
	we fail a couple, due to the fact that it seems StringValidator on
	MS (at least in this case) doesn't actually check the MinLength
	requirement when the value is null.  I'm a bit confused by this.

	* System.Configuration/StringValidatorTest.cs: add a null
	validation check.


svn path=/trunk/mcs/; revision=53867
Chris Toshok 20 tahun lalu
induk
melakukan
afc4da9d07

+ 1 - 0
mcs/class/System.Configuration/System.Configuration_test.dll.sources

@@ -4,6 +4,7 @@ System.Configuration/CommaDelimitedStringCollectionTest.cs
 System.Configuration/ConfigurationLockCollectionTest.cs
 System.Configuration/ConfigurationPermissionTest.cs
 System.Configuration/ConfigurationManagerTest.cs
+System.Configuration/ConnectionStringSettingsTest.cs
 System.Configuration/DefaultValidatorTest.cs
 System.Configuration/ExeConfigurationFileMapTest.cs
 System.Configuration/GenericEnumConverterTest.cs

+ 10 - 0
mcs/class/System.Configuration/Test/ChangeLog

@@ -1,3 +1,13 @@
+2005-12-02  Chris Toshok  <[email protected]>
+
+	* System.Configuration/ConnectionStringSettingsTest.cs: new tests.
+	we fail a couple, due to the fact that it seems StringValidator on
+	MS (at least in this case) doesn't actually check the MinLength
+	requirement when the value is null.  I'm a bit confused by this.
+
+	* System.Configuration/StringValidatorTest.cs: add a null
+	validation check.
+
 2005-11-14  Chris Toshok  <[email protected]>
 
 	* System.Configuration/CommaDelimitedStringCollectionConverterTest.cs:

+ 128 - 0
mcs/class/System.Configuration/Test/System.Configuration/ConnectionStringSettingsTest.cs

@@ -0,0 +1,128 @@
+//
+// System.Configuration.ConnectionStringSettingsTest.cs - Unit tests
+// for System.Configuration.ConnectionStringSettings
+//
+// Author:
+//	Chris Toshok  <[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.
+//
+
+#if NET_2_0
+
+using System;
+using System.Configuration;
+using NUnit.Framework;
+
+namespace MonoTests.System.Configuration {
+	[TestFixture]
+	public class ConnectionStringSettingsTest
+	{
+		[Test]
+		public void Defaults ()
+		{
+			ConnectionStringSettings s;
+
+			s = new ConnectionStringSettings ();
+
+			Assert.AreEqual (null, s.Name, "A1");
+			Assert.AreEqual ("", s.ProviderName, "A2");
+			Assert.AreEqual ("", s.ConnectionString, "A3");
+
+			s = new ConnectionStringSettings ("name", "connectionString");
+			Assert.AreEqual ("name", s.Name, "A4");
+			Assert.AreEqual ("", s.ProviderName, "A5");
+			Assert.AreEqual ("connectionString", s.ConnectionString, "A6");
+
+			s = new ConnectionStringSettings ("name", "connectionString", "provider");
+			Assert.AreEqual ("name", s.Name, "A7");
+			Assert.AreEqual ("provider", s.ProviderName, "A8");
+			Assert.AreEqual ("connectionString", s.ConnectionString, "A9");
+		}
+
+		[Test]
+		public void NameNull ()
+		{
+			ConnectionStringSettings s;
+
+			s = new ConnectionStringSettings ("name", "connectionString", "provider");
+			Assert.AreEqual ("name", s.Name, "A1");
+			s.Name = null;
+			Assert.AreEqual (null, s.Name, "A2");
+		}
+
+		[Test]
+		[ExpectedException (typeof(ConfigurationErrorsException))]
+		public void Validators_Name1 ()
+		{
+			ConnectionStringSettings s = new ConnectionStringSettings ();
+			s.Name = "";
+		}
+
+		[Test]
+		public void Validators_Name2 ()
+		{
+			ConnectionStringSettings s = new ConnectionStringSettings ();
+ 			s.Name = null;
+		}
+
+		[Test]
+		public void Validators_ProviderName1 ()
+		{
+			ConnectionStringSettings s = new ConnectionStringSettings ();
+			s.ProviderName = "";
+		}
+
+		[Test]
+		public void Validators_ProviderName2 ()
+		{
+			ConnectionStringSettings s = new ConnectionStringSettings ();
+			s.ProviderName = null;
+		}
+
+		[Test]
+		public void Validators_ConnectionString1 ()
+		{
+			ConnectionStringSettings s = new ConnectionStringSettings ();
+			s.ConnectionString = "";
+		}
+
+		[Test]
+		public void Validators_ConnectionString2 ()
+		{
+			ConnectionStringSettings s = new ConnectionStringSettings ();
+			s.ConnectionString = null;
+		}
+
+		[Test]
+		public void ToString ()
+		{
+			ConnectionStringSettings s;
+
+			s = new ConnectionStringSettings ("name", "connectionString", "provider");
+
+			Assert.AreEqual ("connectionString", s.ToString(), "A1");
+		}
+	}
+}
+
+#endif

+ 9 - 0
mcs/class/System.Configuration/Test/System.Configuration/StringValidatorTest.cs

@@ -47,6 +47,15 @@ namespace MonoTests.System.Configuration {
 			Assert.IsFalse (v.CanValidate (typeof (object)));
 		}
 
+		[Test]
+		[ExpectedException (typeof (ArgumentException))]
+		public void Null ()
+		{
+			StringValidator v = new StringValidator (1);
+
+			v.Validate (null);
+		}
+
 		[Test]
 		public void MinLenth ()
 		{