19 using NUnit.Framework;
21 namespace Deveel.Data.Configuration {
28 Assert.IsNotNull(config);
29 Assert.IsNull(config.
Parent);
30 Assert.IsNull(config.
Source);
37 Assert.IsNotNull(config);
38 Assert.DoesNotThrow(() => config.
SetValue(
"test.oneKey", 54));
39 Assert.DoesNotThrow(() => config.
SetValue(
"test.twoKeys", null));
44 Assert.DoesNotThrow(() => value1 = config.
GetValue(
"test.oneKey"));
45 Assert.IsNotNull(value1);
46 Assert.IsInstanceOf<
int>(value1);
47 Assert.AreEqual(54, value1);
49 Assert.DoesNotThrow(() => value2 = config.
GetValue(
"test.twoKeys"));
50 Assert.IsNull(value2);
57 Assert.IsNotNull(config);
59 Assert.DoesNotThrow(() => config.
SetValue(
"test.oneKey",
"one"));
63 Assert.IsNotNull(child);
64 Assert.IsNotNull(child.
Parent);
66 Assert.DoesNotThrow(() => child.
SetValue(
"test.oneKey", 45));
69 Assert.DoesNotThrow(() => value = child.
GetValue(
"test.oneKey"));
70 Assert.IsNotNull(value);
71 Assert.IsInstanceOf<
int>(value);
72 Assert.AreEqual(45, value);
74 Assert.DoesNotThrow(() => value = config.
GetValue(
"test.oneKey"));
75 Assert.IsNotNull(value);
76 Assert.IsInstanceOf<
string>(value);
77 Assert.AreEqual(
"one", value);
84 Assert.IsNotNull(config);
86 Assert.DoesNotThrow(() => config.
SetValue(
"test.oneKey",
"22"));
89 Assert.DoesNotThrow(() => value = config.GetInt32(
"test.oneKey"));
90 Assert.IsNotNull(value);
91 Assert.IsInstanceOf<
int>(value);
92 Assert.AreEqual(22, value);
95 [TestCase(
"test",
"true",
true)]
96 [TestCase(
"test",
"false",
false)]
97 [TestCase(
"test",
"off",
false)]
98 [TestCase(
"test",
"on",
true)]
99 [TestCase(
"test",
"enabled",
true)]
103 Assert.IsNotNull(config);
105 Assert.DoesNotThrow(() => config.
SetValue(key, value));
107 object configValue = null;
108 Assert.DoesNotThrow(() => configValue = config.GetBoolean(key));
109 Assert.IsNotNull(configValue);
110 Assert.IsInstanceOf<
bool>(configValue);
111 Assert.AreEqual(expected, configValue);
114 [TestCase(1, TestEnum.One)]
115 [TestCase(
"one", TestEnum.One)]
116 [TestCase(
"TWO", TestEnum.Two)]
117 [TestCase(null, TestEnum.Default)]
121 Assert.IsNotNull(config);
123 Assert.DoesNotThrow(() => config.
SetValue(
"test", value));
125 object configValue = null;
127 Assert.IsInstanceOf<
TestEnum>(configValue);
128 Assert.AreEqual(expected, configValue);
139 var properties =
new StringBuilder();
140 properties.AppendLine(
"system.readOnly = false");
141 properties.AppendLine(
"caching.type = Memory");
145 Assert.IsNotNull(configuration);
148 Assert.DoesNotThrow(() => Assert.IsNotNull(configuration.
GetValue(
"system.readOnly")));
150 bool readOnly =
true;
151 Assert.DoesNotThrow(() => readOnly = configuration.GetBoolean(
"system.readOnly"));
152 Assert.IsFalse(readOnly);
object GetValue(string key)
Gets a configuration setting for the given key.
IConfigSource Source
Gets or sets an optional source of the configuration object
void GetBooleanValue(string key, string value, bool expected)
void GetEnumValue(object value, TestEnum expected)
void SetValue(string key, object value)
Sets a given value for a key defined by this object.
IConfiguration Parent
Gets or sets an optional parent object of this configuration.
Defines the contract for the configuration node of a component within the system or of the system its...
void GetValuesFromChild()
void Extensions_LoadFromProperties()