public void SaveWithDefaultValues_ShouldReturnDefaultValues() { IniTestClass iniHandler = new IniTestClass("temp_unittests.ini"); //Overwrite any potential changed data since ClassInitialize iniHandler.SaveConfig(); //Change the data then load the same file again, should contain the defaults from IniTestClass iniHandler.Integer++; iniHandler.Double++; iniHandler.Float++; iniHandler.Decimal++; iniHandler.String += "d"; iniHandler.Char = 'e'; iniHandler.DateTime.AddDays(1); iniHandler.Boolean = false; iniHandler.LoadConfig(); Assert.AreEqual(-1, iniHandler.Integer); Assert.AreEqual(1.3d, iniHandler.Double); Assert.AreEqual(2.5f, iniHandler.Float); Assert.AreEqual(3.7m, iniHandler.Decimal); Assert.AreEqual("abc 123", iniHandler.String); Assert.AreEqual('d', iniHandler.Char); Assert.AreEqual(new DateTime(2000, 02, 06), iniHandler.DateTime); Assert.AreEqual(true, iniHandler.Boolean); }
public void SaveToFile_ShouldOnlySavePublicProperties() { IniTestClass iniHandler = new IniTestClass("temp_unittests.ini"); iniHandler.SaveConfig(); iniHandler.ChangePrivates(); iniHandler.LoadConfig(); Assert.AreEqual(true, iniHandler.ArePrivateEmpty()); }
public void SaveToFile_ShouldNotContainBaseClassProps() { IniTestClass iniHandler = new IniTestClass("temp_unittests.ini"); iniHandler.SaveConfig(); Assert.AreEqual(true, File.Exists("temp_unittests.ini")); string text = File.ReadAllText("temp_unittests.ini"); Assert.AreEqual(false, text.Contains("FilePath")); }
public void ChangeDate_ShouldReturnChangedDate() { IniTestClass iniHandler = new IniTestClass("temp_unittests.ini"); //Add two days and save to the file iniHandler.DateTime = iniHandler.DateTime.AddDays(2); iniHandler.SaveConfig(); //Change the date, then load it back from file to reset it iniHandler.DateTime.AddDays(-15); iniHandler.LoadConfig(); Assert.AreEqual(new DateTime(2000, 02, 08), iniHandler.DateTime); }