Exemple #1
0
        public void GeyKey_data_retrieval()
        {
            var    input     = @"
global = 1
[section]
key = 2
";
            var    data      = new IniDataParser().Parse(input);
            var    separator = data.SectionKeySeparator;
            string key;

            // should succeed
            key = "global";
            Assert.AreEqual(data.GetKey(key), "1");

            key = string.Format("section{0}key", separator);
            Assert.AreEqual(data.GetKey(key), "2");

            // should fail
            key = null;
            Assert.IsNull(data.GetKey(key));

            key = "badglobal";
            Assert.IsNull(data.GetKey(key));

            key = string.Format("badsection{0}badkey", separator);
            Assert.IsNull(data.GetKey(key));
        }