Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Köplinger <alex.koeplinger@outlook.com>2016-09-05 21:20:16 +0300
committerAlexander Köplinger <alex.koeplinger@outlook.com>2016-10-29 15:09:35 +0300
commit2550144e79a3cda870c51c8721f0796c53397dfd (patch)
tree08d4cf039706ba32f782db305110fb30f54b8b9c /mcs/class/System.Configuration
parentf1ae0bcaaec398f04c9e6ee31b995358efca8240 (diff)
[corlib/System/System.Configuration] Fix tests relying on the current directory to be the test folder
nunitlite runs tests shadow-copied in a temp folder, so looking up the resource based on the current dir doesn't work.
Diffstat (limited to 'mcs/class/System.Configuration')
-rw-r--r--mcs/class/System.Configuration/Makefile3
-rw-r--r--mcs/class/System.Configuration/Test/System.Configuration/AppSettingsSectionTest.cs4
-rw-r--r--mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs10
-rw-r--r--mcs/class/System.Configuration/Test/Util/TestUtil.cs9
-rw-r--r--mcs/class/System.Configuration/Test/test-config-file2
5 files changed, 12 insertions, 16 deletions
diff --git a/mcs/class/System.Configuration/Makefile b/mcs/class/System.Configuration/Makefile
index 00fdc43d3e1..e6f48050a99 100644
--- a/mcs/class/System.Configuration/Makefile
+++ b/mcs/class/System.Configuration/Makefile
@@ -21,6 +21,9 @@ configuration_library_deps = \
$(build_lib): $(configuration_library_deps)
+test-local:
+ cp Test/appSettings.config $(dir $(NUNITLITE_CONFIG_FILE))/Test-appSettings.config
+
.NOTPARALLEL: $(configuration_library_deps)
$(secxml_libdir)/System.dll:
diff --git a/mcs/class/System.Configuration/Test/System.Configuration/AppSettingsSectionTest.cs b/mcs/class/System.Configuration/Test/System.Configuration/AppSettingsSectionTest.cs
index 83e87e21b6a..f0445810330 100644
--- a/mcs/class/System.Configuration/Test/System.Configuration/AppSettingsSectionTest.cs
+++ b/mcs/class/System.Configuration/Test/System.Configuration/AppSettingsSectionTest.cs
@@ -65,9 +65,9 @@ namespace MonoTests.System.Configuration
{
Directory.SetCurrentDirectory (tempFolder);
- var currentAssembly = Assembly.GetExecutingAssembly ().Location;
+ var currentAssembly = TestUtil.ThisApplicationPath;
var config = ConfigurationManager.OpenExeConfiguration (currentAssembly);
- Assert.AreEqual ("Test/appSettings.config", config.AppSettings.File, "#A01");
+ Assert.AreEqual ("Test-appSettings.config", config.AppSettings.File, "#A01");
Assert.AreEqual ("foo", ConfigurationSettings.AppSettings["TestKey1"], "#A02");
Assert.AreEqual ("bar", ConfigurationSettings.AppSettings["TestKey2"], "#A03");
}
diff --git a/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs b/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs
index 7efff1dddff..0b5b3cde0dc 100644
--- a/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs
+++ b/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs
@@ -257,10 +257,9 @@ namespace MonoTests.System.Configuration {
[Test]
public void exePath_UserLevelNone ()
{
- string basedir = AppDomain.CurrentDomain.BaseDirectory;
- string name = TestUtil.ThisDllName;
+ string name = TestUtil.ThisApplicationPath;
SysConfig config = ConfigurationManager.OpenExeConfiguration (name);
- Assert.AreEqual (Path.Combine (basedir, name + ".config"), config.FilePath);
+ Assert.AreEqual (TestUtil.ThisApplicationPath + ".config", config.FilePath);
}
[Test]
@@ -615,11 +614,6 @@ namespace MonoTests.System.Configuration {
[Test]
public void TestConnectionStringRetrieval ()
{
- var currentAssembly = Assembly.GetExecutingAssembly().Location;
- Assert.IsTrue (File.Exists (currentAssembly + ".config"),
- String.Format ("This test cannot succeed without the .config file being in the same place as the assembly ({0})",
- currentAssembly));
-
var connStringObj = ConfigurationManager.ConnectionStrings ["test-connstring"];
Assert.IsNotNull (connStringObj);
var connString = connStringObj.ConnectionString;
diff --git a/mcs/class/System.Configuration/Test/Util/TestUtil.cs b/mcs/class/System.Configuration/Test/Util/TestUtil.cs
index 6faeba67a14..497a8a8081d 100644
--- a/mcs/class/System.Configuration/Test/Util/TestUtil.cs
+++ b/mcs/class/System.Configuration/Test/Util/TestUtil.cs
@@ -64,17 +64,16 @@ namespace MonoTests.System.Configuration.Util {
}
}
- public static string ThisDllName {
+ public static string ThisApplicationPath {
get {
- var asm = Assembly.GetCallingAssembly ();
- return Path.GetFileName (asm.Location);
+ var asm = Assembly.GetEntryAssembly ();
+ return asm.Location;
}
}
public static string ThisConfigFileName {
get {
- var asm = Assembly.GetCallingAssembly ();
- var exe = Path.GetFileName (asm.Location);
+ var exe = Path.GetFileName (ThisApplicationPath);
return exe + ".config";
}
}
diff --git a/mcs/class/System.Configuration/Test/test-config-file b/mcs/class/System.Configuration/Test/test-config-file
index 1e8d47f1471..5920c6c2ab0 100644
--- a/mcs/class/System.Configuration/Test/test-config-file
+++ b/mcs/class/System.Configuration/Test/test-config-file
@@ -2,4 +2,4 @@
<add name="test-connstring"
connectionString="Server=(local);Initial Catalog=someDb;User Id=someUser;Password=somePassword;Application Name=someAppName;Min Pool Size=5;Max Pool Size=500;Connect Timeout=10;Connection Lifetime=29;" />
</connectionStrings>
- <appSettings file="Test/appSettings.config" />
+ <appSettings file="Test-appSettings.config" />