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); }
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 != "")); } }
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); } }
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]); } }