* ConfigurationManagerTest.cs: Added/improved tests for
[mono.git] / mcs / class / System.Configuration / Test / standalone / t12.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Collections.Specialized;
4 using System.Text;
5 using System.Configuration;
6 using System.Web;
7
8 // test to see how we react when the default value for an attribute is
9 // of the wrong type.
10 public class CustomSection :  ConfigurationSection
11 {
12         public CustomSection()
13         {
14         }
15   
16         [LongValidator(MinValue = 1, MaxValue = 1000000,
17                        ExcludeRange = false)]
18         [ConfigurationProperty ("longSetting", DefaultValue="wrong type")]
19         public long LongSetting
20         {
21                 get { return (long)this["longSetting"]; }
22                 set { this["longSetting"] = value; }
23         }
24 }
25
26 class T1
27 {
28         static void Main(string[] args)
29         {
30                 try
31                 {
32                         Console.WriteLine ("1");
33                         Configuration config = ConfigurationManager.OpenExeConfiguration (ConfigurationUserLevel.None);
34                         Console.WriteLine ("2");
35                         CustomSection sect = (CustomSection)config.GetSection("customSection");
36
37                         Console.WriteLine ("longSetting = {0}", sect.LongSetting);
38                 }
39                 catch (Exception e)
40                 {
41                         Console.WriteLine ("Exception raised: {0}", e.GetType());
42                 }
43         }
44 }