public void ShouldLoadMultipleSectionsAndKeys_NotCaringAboutKeyOrSectionCase() { using (var tempFile = new AutoDeletingTempFile(".ini")) { //---------------Set up test pack------------------- var lines = new[] { "[Section1]", "path=\"C:\\tmp\\something.txt\"", "color=Red", "", "[Section2]", "number=12", "Season = Green" }; tempFile.Write(lines); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var iniFile = Create(tempFile.Path); //---------------Test Result ----------------------- Assert.AreEqual("C:\\tmp\\something.txt", iniFile.Data["Section1"]["path"]); Assert.AreEqual("Red", iniFile.Data["Section1"]["color"]); Assert.AreEqual("12", iniFile.Data["section2"]["number"]); Assert.AreEqual("Green", iniFile.Data["Section2"]["season"]); } }
public void ShouldLoadMultipleSectionsAndKeys_WithCaseInsensitivityForSectionNamesAndSettingNames() { using (var tempFile = new AutoDeletingTempFile(".ini")) { //---------------Set up test pack------------------- var lines = new[] { "[Section1]", "path=\"C:\\tmp\\something.txt\"", "color=Red", "", "[Section2]", "number=12", "Season = Green" }; tempFile.Write(lines); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var sut = Create(tempFile.Path); //---------------Test Result ----------------------- Expect(sut.Data["Section1"]) .To.Contain.Key("path") .With.Value("C:\\tmp\\something.txt"); Expect(sut.Data["Section1"]) .To.Contain.Key("color") .With.Value("Red"); Expect(sut.Data["section2"]) .To.Contain.Key("number") .With.Value("12"); // NExpect doesn't know (yet) how to tell that the Expect(sut.Data["sectioN2"]["NUMber"]) .To.Equal("12"); Expect(sut.Data["Section2"]) .To.Contain.Key("Season") .With.Value("Green"); } }
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]); } }
public void 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---------------- Expect(tempFile.Path).To.Be.A.File(); //---------------Execute Test ---------------------- var sut = Create(tempFile.Path); //---------------Test Result ----------------------- Expect(sut.Data).Not.To.Be.Null(); Expect(sut.Data).To.Contain.Key(section); Expect(sut.Data[section]).To.Contain.Key(key) .With.Value(value); } }