2005-12-02 Chris Toshok <toshok@ximian.com>
authorChris Toshok <toshok@novell.com>
Sat, 3 Dec 2005 01:39:12 +0000 (01:39 -0000)
committerChris Toshok <toshok@novell.com>
Sat, 3 Dec 2005 01:39:12 +0000 (01:39 -0000)
* 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

mcs/class/System.Configuration/System.Configuration_test.dll.sources
mcs/class/System.Configuration/Test/ChangeLog
mcs/class/System.Configuration/Test/System.Configuration/ConnectionStringSettingsTest.cs [new file with mode: 0644]
mcs/class/System.Configuration/Test/System.Configuration/StringValidatorTest.cs

index a9bcfad53e0d7609f7b120656075077b942213ec..14b6b3122c6eddd6aa47b53d84485a4b2ad8fcb0 100644 (file)
@@ -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
index 55180795f824c9236a0e1c035a9c5f780931fdff..9d4597b9043ca019a778127c94eec82fab726004 100644 (file)
@@ -1,3 +1,13 @@
+2005-12-02  Chris Toshok  <toshok@ximian.com>
+
+       * 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  <toshok@ximian.com>
 
        * System.Configuration/CommaDelimitedStringCollectionConverterTest.cs:
diff --git a/mcs/class/System.Configuration/Test/System.Configuration/ConnectionStringSettingsTest.cs b/mcs/class/System.Configuration/Test/System.Configuration/ConnectionStringSettingsTest.cs
new file mode 100644 (file)
index 0000000..58e62b0
--- /dev/null
@@ -0,0 +1,128 @@
+//
+// System.Configuration.ConnectionStringSettingsTest.cs - Unit tests
+// for System.Configuration.ConnectionStringSettings
+//
+// Author:
+//     Chris Toshok  <toshok@ximian.com>
+//
+// 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
index 6007a012aeeb57e10e6fe7c8afd7eba2ce32daef..a79472dd58efb66d1dfb138bfbe263f95835a4d1 100644 (file)
@@ -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 ()
                {