Esempio n. 1
0
            public void ReturnsNullWhenNotFoundAndNotRequired()
            {
                IConfig config = new Config();
                string result = config.GetConfigValue("doesnt-exist", isRequired: false);

                Assert.IsNull(result);
            }
Esempio n. 2
0
            public void ReturnsTheDefaultValueWhenConfigValueNotFound()
            {
                IConfig config = new Config();
                string expectedResult = "default-value";
                string actualResult = config.GetConfigValue("doesnt-exist", false, defaultValue: expectedResult);

                Assert.AreEqual(expectedResult, actualResult);
            }
Esempio n. 3
0
            public void ReturnsTheRequestedValue()
            {
                // <add key="sampleSetting" value="default-value"/>
                IConfig config = new Config();

                string settingName = "sampleSetting";
                string expectedResult = "default-value";
                string actualResult = config.GetConfigValue(settingName);

                Assert.AreEqual(expectedResult, actualResult);
            }
Esempio n. 4
0
 public void ThrowsWhenNotFoundAndRequired()
 {
     IConfig config = new Config();
     string result = config.GetConfigValue("doesnt-exist", isRequired: true);
 }
Esempio n. 5
0
 public void ThrowsWhenTheValueIsNotInConfigAndRequired()
 {
     IConfig config = new Config();
     IList<string> actualResult = config.GetList("doesnt-exist", isRequired: true);
 }
Esempio n. 6
0
            public void ReturnsTheGivenList()
            {
                IConfig config = new Config();
                IList<string> actualResult = config.GetList("sampleList");

                IList<string> expectedResult = new List<string> { "one", "two", "three", "four" };

                CustomAssert.AreEqual<string>(expectedResult, actualResult, (x, y) => { Assert.AreEqual(x, y); });
            }
Esempio n. 7
0
            public void ReturnsTheExpectedResultWhenACustomDelimterIsUsed()
            {
                IConfig config = new Config();
                IList<string> actualResult = config.GetList("sampleList-customDelim",delimiter:'|');

                IList<string> expectedResult = new List<string> { "one", "two", "three", "four" };

                CustomAssert.AreEqual<string>(expectedResult, actualResult, (x, y) => { Assert.AreEqual(x, y); });
            }
Esempio n. 8
0
            public void ReturnsTheDefaultValueWhenConfigValueNotFound()
            {
                IConfig config = new Config();
                IList<string> expectedResult = new List<string> { "default", "value", "here" };
                IList<string> actualResult = config.GetList("doesnt-exist", defaultValue: expectedResult);

                Assert.AreEqual(expectedResult, actualResult);
            }
Esempio n. 9
0
            public void ReturnsNullWhenNotInConfigAndNotRequired()
            {
                IConfig config = new Config();
                IList<string> actualResult = config.GetList("doesnt-exist", isRequired: false);

                Assert.IsNull(actualResult);
            }