* Makefile: added test t46.
authorGert Driesen <drieseng@users.sourceforge.net>
Wed, 2 Jul 2008 10:26:50 +0000 (10:26 -0000)
committerGert Driesen <drieseng@users.sourceforge.net>
Wed, 2 Jul 2008 10:26:50 +0000 (10:26 -0000)
* t46.cs, t46-lib.cs: added test for bug #405574.
* t46.exe.config, t46.exe.config2: config files for t46.
* t46.exe.expected: expected result for t46.

svn path=/trunk/mcs/; revision=107049

mcs/class/System.Configuration/Test/standalone/ChangeLog
mcs/class/System.Configuration/Test/standalone/Makefile
mcs/class/System.Configuration/Test/standalone/t46-lib.cs [new file with mode: 0644]
mcs/class/System.Configuration/Test/standalone/t46.cs [new file with mode: 0644]
mcs/class/System.Configuration/Test/standalone/t46.exe.config [new file with mode: 0644]
mcs/class/System.Configuration/Test/standalone/t46.exe.config2 [new file with mode: 0644]
mcs/class/System.Configuration/Test/standalone/t46.exe.expected [new file with mode: 0644]

index 671bddf7a8ab1e56fbbd30ca49336059b00783b8..916dac14245e63e5b4db34693987e045100ad1b5 100644 (file)
@@ -1,3 +1,10 @@
+2008-07-02  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * Makefile: added test t46.
+       * t46.cs, t46-lib.cs: added test for bug #405574.
+       * t46.exe.config, t46.exe.config2: config files for t46.
+       * t46.exe.expected: expected result for t46.
+
 2008-06-26  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * Assert.cs: added.
index 303bae5986c3b79012450959ecd9bf4d158689a5..98fd59cf7000fa715df37f51ae36ea6c4454d305 100644 (file)
@@ -1,4 +1,4 @@
-TESTS = t1.exe t2.exe t3.exe t4.exe t5.exe t6.exe t7.exe t8.exe t9.exe t10.exe t11.exe t12.exe t15.exe t16.exe t17.exe t18.exe t19.exe t20.exe t21.exe t22.exe t23.exe t24.exe t25.exe t26.exe t27.exe t28.exe t29.exe t30.exe t31.exe t32.exe t33.exe t34.exe t35.exe t36.exe t37.exe t38.exe t39.exe t40.exe t41.exe t42.exe t43.exe t44.exe t45.exe
+TESTS = t1.exe t2.exe t3.exe t4.exe t5.exe t6.exe t7.exe t8.exe t9.exe t10.exe t11.exe t12.exe t15.exe t16.exe t17.exe t18.exe t19.exe t20.exe t21.exe t22.exe t23.exe t24.exe t25.exe t26.exe t27.exe t28.exe t29.exe t30.exe t31.exe t32.exe t33.exe t34.exe t35.exe t36.exe t37.exe t38.exe t39.exe t40.exe t41.exe t42.exe t43.exe t44.exe t45.exe t46.exe
 # t13.exe t14.exe
 
 check: local compare
@@ -22,5 +22,9 @@ t36.exe : t36.cs t36-lib.cs
        gmcs /debug -r:System.Configuration.dll -t:library t36-lib.cs
        gmcs /debug -r:System.Configuration.dll -r:t36-lib.dll t36.cs
 
+t46.exe : t46.cs t46-lib.cs
+       gmcs /debug -r:System.Configuration.dll -t:library t46-lib.cs
+       gmcs /debug -r:System.Configuration.dll -r:t46-lib.dll /out:$@ Assert.cs t46.cs
+
 %.exe: %.cs
        gmcs /debug /out:$@ Assert.cs $< -r:System.Configuration.dll -r:System.Web.dll -r:System.Data.dll
diff --git a/mcs/class/System.Configuration/Test/standalone/t46-lib.cs b/mcs/class/System.Configuration/Test/standalone/t46-lib.cs
new file mode 100644 (file)
index 0000000..1d88502
--- /dev/null
@@ -0,0 +1,31 @@
+using System;
+using System.Configuration;
+using System.Reflection;
+
+public class Foo : MarshalByRefObject
+{
+       public static Foo GetRemote (AppDomain domain)
+       {
+               Foo test = (Foo) domain.CreateInstanceAndUnwrap (
+                       typeof (Foo).Assembly.FullName,
+                       typeof (Foo).FullName, new object [0]);
+               return test;
+       }
+
+       public string GetFilePath (string exePath)
+       {
+               Configuration config = ConfigurationManager.OpenExeConfiguration (exePath);
+               return config.FilePath;
+       }
+
+       public Configuration OpenExeConfiguration (string exePath)
+       {
+               return ConfigurationManager.OpenExeConfiguration (exePath);
+       }
+
+       public string GetSettingValue (string exePath, string key)
+       {
+               Configuration config = OpenExeConfiguration (exePath);
+               return config.AppSettings.Settings [key].Value;
+       }
+}
diff --git a/mcs/class/System.Configuration/Test/standalone/t46.cs b/mcs/class/System.Configuration/Test/standalone/t46.cs
new file mode 100644 (file)
index 0000000..72af6ef
--- /dev/null
@@ -0,0 +1,77 @@
+using System;
+using System.Configuration;
+using System.IO;
+
+class Program : MarshalByRefObject
+{
+       static void Main (string [] args)
+       {
+               AppDomainSetup setup = new AppDomainSetup ();
+
+               string basedir = AppDomain.CurrentDomain.BaseDirectory;
+               setup.ConfigurationFile = Path.Combine (AppDomain.CurrentDomain.BaseDirectory,
+                       "t46.exe.config2");
+
+               AppDomain domain = AppDomain.CreateDomain ("test",
+                       AppDomain.CurrentDomain.Evidence, setup);
+
+               Program p;
+               Configuration c;
+
+               p = GetRemote (domain);
+               Assert.AreEqual (Path.Combine (basedir, "t46.exe.config2"),
+                       p.GetFilePath (string.Empty), "#A1");
+               Assert.AreEqual ("Hello World2!",
+                       p.GetSettingValue (string.Empty, "hithere"), "#A2");
+
+               p = new Program ();
+
+               c = p.OpenExeConfiguration (string.Empty);
+               Assert.AreEqual (Path.Combine (basedir, "t46.exe.config"),
+                       c.FilePath, "#B1");
+               Assert.AreEqual ("Hello World!",
+                       c.AppSettings.Settings ["hithere"].Value, "#B2");
+
+               Foo f;
+               
+               f = Foo.GetRemote (domain);
+               Assert.AreEqual (Path.Combine (basedir, "t46.exe.config2"),
+                       f.GetFilePath (string.Empty), "#C1");
+               Assert.AreEqual ("Hello World2!",
+                       f.GetSettingValue (string.Empty, "hithere"), "#C2");
+
+               f = new Foo ();
+               c = f.OpenExeConfiguration (string.Empty);
+               Assert.AreEqual (Path.Combine (basedir, "t46.exe.config"),
+                       c.FilePath, "#D1");
+               Assert.AreEqual ("Hello World!",
+                       c.AppSettings.Settings ["hithere"].Value, "#D2");
+
+               Console.WriteLine ("configuration OK");
+       }
+
+       static Program GetRemote (AppDomain domain)
+       {
+               Program test = (Program) domain.CreateInstanceAndUnwrap (
+                       typeof (Program).Assembly.FullName,
+                       typeof (Program).FullName, new object [0]);
+               return test;
+       }
+
+       public string GetFilePath (string exePath)
+       {
+               Configuration config = ConfigurationManager.OpenExeConfiguration (exePath);
+               return config.FilePath;
+       }
+
+       public Configuration OpenExeConfiguration (string exePath)
+       {
+               return ConfigurationManager.OpenExeConfiguration (exePath);
+       }
+
+       public string GetSettingValue (string exePath, string key)
+       {
+               Configuration config = OpenExeConfiguration (exePath);
+               return config.AppSettings.Settings [key].Value;
+       }
+}
diff --git a/mcs/class/System.Configuration/Test/standalone/t46.exe.config b/mcs/class/System.Configuration/Test/standalone/t46.exe.config
new file mode 100644 (file)
index 0000000..86ab1c6
--- /dev/null
@@ -0,0 +1,5 @@
+<configuration>
+       <appSettings>
+               <add key="hithere" value="Hello World!"/>
+       </appSettings>
+</configuration>
diff --git a/mcs/class/System.Configuration/Test/standalone/t46.exe.config2 b/mcs/class/System.Configuration/Test/standalone/t46.exe.config2
new file mode 100644 (file)
index 0000000..d46aadf
--- /dev/null
@@ -0,0 +1,5 @@
+<configuration>
+       <appSettings>
+               <add key="hithere" value="Hello World2!"/>
+       </appSettings>
+</configuration>
diff --git a/mcs/class/System.Configuration/Test/standalone/t46.exe.expected b/mcs/class/System.Configuration/Test/standalone/t46.exe.expected
new file mode 100644 (file)
index 0000000..403d828
--- /dev/null
@@ -0,0 +1 @@
+configuration OK