30 using NUnit.Framework;
31 using OpenSim.Framework;
32 using OpenSim.Tests.Common;
34 namespace OpenSim.Tests
39 private const string m_testSubdirectory =
"test";
40 private string m_basePath;
41 private string m_workingDirectory;
42 private IConfigSource m_config;
52 m_basePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
53 string path = Path.Combine(m_basePath, m_testSubdirectory);
54 Directory.CreateDirectory(path);
55 m_workingDirectory = Directory.GetCurrentDirectory();
56 Directory.SetCurrentDirectory(path);
65 Directory.SetCurrentDirectory(m_workingDirectory);
66 Directory.Delete(m_basePath,
true);
75 const string mainIniFile =
"OpenSimDefaults.ini";
76 m_config =
new IniConfigSource();
82 ini =
new IniConfigSource();
83 config = ini.AddConfig(
"IncludeTest");
84 config.Set(
"Include-absolute",
"absolute/*/config/*.ini");
85 config.Set(
"Include-relative",
"../" + m_testSubdirectory +
"/relative/*/config/*.ini");
86 CreateIni(mainIniFile, ini);
88 ini =
new IniConfigSource();
89 ini.AddConfig(
"Absolute1").Set(
"name1",
"value1");
90 CreateIni(
"absolute/one/config/setting.ini", ini);
92 ini =
new IniConfigSource();
93 ini.AddConfig(
"Absolute2").Set(
"name2", 2.3);
94 CreateIni(
"absolute/two/config/setting1.ini", ini);
96 ini =
new IniConfigSource();
97 ini.AddConfig(
"Absolute2").Set(
"name3",
"value3");
98 CreateIni(
"absolute/two/config/setting2.ini", ini);
100 ini =
new IniConfigSource();
101 ini.AddConfig(
"Relative1").Set(
"name4",
"value4");
102 CreateIni(
"relative/one/config/setting.ini", ini);
104 ini =
new IniConfigSource();
105 ini.AddConfig(
"Relative2").Set(
"name5",
true);
106 CreateIni(
"relative/two/config/setting1.ini", ini);
108 ini =
new IniConfigSource();
109 ini.AddConfig(
"Relative2").Set(
"name6", 6);
110 CreateIni(
"relative/two/config/setting2.ini", ini);
114 IConfigSource argvSource =
new IniConfigSource();
115 EnvConfigSource envConfigSource =
new EnvConfigSource();
116 argvSource.AddConfig(
"Startup").Set(
"inifile", mainIniFile);
121 out configSettings, out networkInfo);
124 config = source.Source.Configs[
"Startup"];
125 source.Source.Configs.Remove(config);
126 config = source.Source.Configs[
"Network"];
127 source.Source.Configs.Remove(config);
130 Assert.AreEqual(m_config.ToString(), source.
Source.ToString(),
131 "Configuration with includes does not contain all settings.");
137 private void CreateIni(
string filepath, IniConfigSource source)
139 string path = Path.GetDirectoryName(filepath);
140 if (path !=
string.Empty)
142 Directory.CreateDirectory(path);
144 source.Save(filepath);
145 m_config.Merge(source);
void TearDown()
Remove the test directory.
Loads the Configuration files into nIni
void IncludeTests()
Test the including of ini files with absolute and relative paths.
override void SetUp()
Set up a test directory.