예제 #1
0
        public void Construct_ShouldNotThrow()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            INIFile_EXPOSES_Sections iniFile = null;
            Assert.DoesNotThrow(() => iniFile = new INIFile_EXPOSES_Sections());

            //---------------Test Result -----------------------
            Assert.IsNotNull(iniFile.Data);
        }
예제 #2
0
        public void Construct_ShouldNotThrow()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            INIFile_EXPOSES_Sections iniFile = null;

            Assert.DoesNotThrow(() => iniFile = new INIFile_EXPOSES_Sections());

            //---------------Test Result -----------------------
            Assert.IsNotNull(iniFile.Data);
        }
예제 #3
0
        public void Construct_GivenFileNameWhichDoesntExist_ShouldNotThrow()
        {
            //---------------Set up test pack-------------------
            using (var tempFile = new AutoDeletingTempFile(".ini"))
            {
                File.Delete(tempFile.Path);
                //---------------Assert Precondition----------------
                Assert.IsFalse(File.Exists(tempFile.Path));
                //---------------Execute Test ----------------------
                INIFile_EXPOSES_Sections iniFile = null;
                Assert.DoesNotThrow(() => iniFile = Create(tempFile.Path));

                //---------------Test Result -----------------------
                Assert.IsNotNull(iniFile.Data);
                Assert.IsFalse(iniFile.Data.Keys.Any(k => k != ""));
            }
        }
예제 #4
0
        public void Construct_GivenFileName_ShouldLoadFile()
        {
            //---------------Set up test pack-------------------
            using (var tempFile = new AutoDeletingTempFile(".ini"))
            {
                var section      = RandString();
                var key          = RandString();
                var value        = RandString();
                var iniDataLines = new[] { "[" + section + "]", key + "=" + value };
                tempFile.Write(iniDataLines);

                //---------------Assert Precondition----------------
                Assert.IsTrue(File.Exists(tempFile.Path));

                //---------------Execute Test ----------------------
                var iniFile = new INIFile_EXPOSES_Sections(tempFile.Path);

                //---------------Test Result -----------------------
                Assert.IsNotNull(iniFile.Data);
                Assert.IsTrue(iniFile.Data.Keys.Contains(section));
                Assert.AreEqual(iniFile.Data[section][key], value);
            }
        }
예제 #5
0
        public void Parse_WhenValueIsQuoted_ShouldSetDataValueUnQuoted()
        {
            //---------------Set up test pack-------------------
            using (var tempFile = new AutoDeletingTempFile(".ini"))
            {
                var section      = RandString();
                var key          = RandString();
                var value        = RandString();
                var iniDataLines = new[] { "[" + section + "]", key + "=\"" + value + "\"" };
                tempFile.Write(iniDataLines);

                //---------------Assert Precondition----------------
                Assert.IsTrue(File.Exists(tempFile.Path));

                //---------------Execute Test ----------------------
                var iniFile = new INIFile_EXPOSES_Sections(tempFile.Path);

                //---------------Test Result -----------------------
                Assert.IsNotNull(iniFile.Data);
                Assert.IsTrue(iniFile.Data.Keys.Contains(section));
                Assert.AreEqual(value, iniFile.Data[section][key]);
            }
        }
예제 #6
0
        public void Construct_GivenFileName_ShouldLoadFile()
        {
            //---------------Set up test pack-------------------
            using (var tempFile = new AutoDeletingTempFile(".ini"))
            {
                var section = RandString();
                var key = RandString();
                var value = RandString();
                var iniDataLines = new[] { "[" + section + "]", key + "=" + value };
                tempFile.Write(iniDataLines);

                //---------------Assert Precondition----------------
                Assert.IsTrue(File.Exists(tempFile.Path));

                //---------------Execute Test ----------------------
                var iniFile = new INIFile_EXPOSES_Sections(tempFile.Path);

                //---------------Test Result -----------------------
                Assert.IsNotNull(iniFile.Data);
                Assert.IsTrue(iniFile.Data.Keys.Contains(section));
                Assert.AreEqual(iniFile.Data[section][key], value);
            }
        }
예제 #7
0
        public void Parse_WhenValueIsQuoted_ShouldSetDataValueUnQuoted()
        {
            //---------------Set up test pack-------------------
            using (var tempFile = new AutoDeletingTempFile(".ini"))
            {
                var section = RandString();
                var key = RandString();
                var value = RandString();
                var iniDataLines = new[] { "[" + section + "]", key + "=\"" + value + "\"" };
                tempFile.Write(iniDataLines);

                //---------------Assert Precondition----------------
                Assert.IsTrue(File.Exists(tempFile.Path));

                //---------------Execute Test ----------------------
                var iniFile = new INIFile_EXPOSES_Sections(tempFile.Path);

                //---------------Test Result -----------------------
                Assert.IsNotNull(iniFile.Data);
                Assert.IsTrue(iniFile.Data.Keys.Contains(section));
                Assert.AreEqual(value, iniFile.Data[section][key]);
            }
        }