Merge branch 'master' of http://github.com/mono/mono
[mono.git] / mcs / class / System.Configuration / Test / standalone / t28.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 class T1
9 {
10         static void Main(string[] args)
11         {
12                 try {
13                         NameValueCollection AppSettings = ConfigurationManager.AppSettings;
14                         Assert.Fail ("#1:" + AppSettings);
15                 } catch (ConfigurationErrorsException ex) {
16                         // Configuration system failed to initialize
17                         Assert.AreEqual (typeof (ConfigurationErrorsException), ex.GetType (), "#2");
18                         Assert.IsNull (ex.Filename, "#3");
19                         Assert.IsNotNull (ex.InnerException, "#6");
20                         Assert.AreEqual (0, ex.Line, "#7");
21                         Assert.IsNotNull (ex.Message, "#8");
22
23                         // <location> sections are allowed only within <configuration> sections
24                         ConfigurationErrorsException inner = ex.InnerException as ConfigurationErrorsException;
25                         Assert.AreEqual (typeof (ConfigurationErrorsException), inner.GetType (), "#9");
26                         Assert.AreEqual (AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, inner.Filename, "#10");
27                         Assert.IsNull (inner.InnerException, "#11");
28                         Assert.AreEqual (3, inner.Line, "#12");
29                         Assert.IsNotNull (inner.Message, "#13");
30                         Assert.IsTrue (inner.Message.IndexOf ("<location>") != -1, "#14:" + inner.Message);
31                         Assert.IsTrue (inner.Message.IndexOf ("<configuration>") != -1, "#15:" + inner.Message);
32
33                         Console.WriteLine ("configuration exception thrown.");
34                 }
35         }
36 }