add test for custom section where the default value's type doesn't match the property
authorChris Toshok <toshok@novell.com>
Fri, 7 Oct 2005 20:59:38 +0000 (20:59 -0000)
committerChris Toshok <toshok@novell.com>
Fri, 7 Oct 2005 20:59:38 +0000 (20:59 -0000)
svn path=/trunk/mcs/; revision=51436

mcs/class/System.Configuration/Test/standalone/t12.cs [new file with mode: 0644]
mcs/class/System.Configuration/Test/standalone/t12.exe.config [new file with mode: 0644]
mcs/class/System.Configuration/Test/standalone/t12.exe.expected [new file with mode: 0644]

diff --git a/mcs/class/System.Configuration/Test/standalone/t12.cs b/mcs/class/System.Configuration/Test/standalone/t12.cs
new file mode 100644 (file)
index 0000000..6590f80
--- /dev/null
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Text;
+using System.Configuration;
+using System.Web;
+
+// test to see how we react when the default value for an attribute is
+// of the wrong type.
+public class CustomSection :  ConfigurationSection
+{
+       public CustomSection()
+       {
+       }
+  
+       [LongValidator(MinValue = 1, MaxValue = 1000000,
+                      ExcludeRange = false)]
+       [ConfigurationProperty ("longSetting", DefaultValue="wrong type")]
+       public long LongSetting
+       {
+               get { return (long)this["longSetting"]; }
+               set { this["longSetting"] = value; }
+       }
+}
+
+class T1
+{
+       static void Main(string[] args)
+       {
+               try
+               {
+                       Console.WriteLine ("1");
+                       Configuration config = ConfigurationManager.OpenExeConfiguration (ConfigurationUserLevel.None);
+                       Console.WriteLine ("2");
+                       CustomSection sect = (CustomSection)config.GetSection("customSection");
+
+                       Console.WriteLine ("longSetting = {0}", sect.LongSetting);
+               }
+               catch (Exception e)
+               {
+                       Console.WriteLine ("Exception raised: {0}", e.GetType());
+               }
+       }
+}
diff --git a/mcs/class/System.Configuration/Test/standalone/t12.exe.config b/mcs/class/System.Configuration/Test/standalone/t12.exe.config
new file mode 100644 (file)
index 0000000..fdb0fe0
--- /dev/null
@@ -0,0 +1,7 @@
+<configuration>
+       <configSections>
+               <section name="customSection" type="CustomSection, t11" />
+       </configSections>
+
+       <customSection longSetting="10" />
+</configuration>
\ No newline at end of file
diff --git a/mcs/class/System.Configuration/Test/standalone/t12.exe.expected b/mcs/class/System.Configuration/Test/standalone/t12.exe.expected
new file mode 100644 (file)
index 0000000..8ceeaaf
--- /dev/null
@@ -0,0 +1,3 @@
+1
+2
+Exception raised: System.Configuration.ConfigurationErrorsException