public void Config_persistence() { // arrange var cfg = new MyTestConfig() { MyNumbericValue = 333, MyStringValue = "abcde", NestedConfig = new MyNestedTestConfig() { NestedValue = "nested abcde" } }; // act cfg.Save(_testFilePathName); // assert Assert.IsTrue(File.Exists(_testFilePathName)); var loadedCfg = Config.Load <MyTestConfig>(_testFilePathName); Assert.AreEqual(cfg.MyStringValue, loadedCfg.MyStringValue); Assert.AreEqual(cfg.MyNumbericValue, loadedCfg.MyNumbericValue); Assert.AreEqual(cfg.NestedConfig.NestedValue, loadedCfg.NestedConfig.NestedValue); }
public void After_load_the_config_knows_its_path() { // arrange var cfg = new MyTestConfig(); cfg.Save(_testFilePathName); // act var loadedCfg = Config.Load <MyTestConfig>(_testFilePathName); // assert Assert.AreEqual(_testFilePathName, loadedCfg.FilePathName); }
public void Save_on_new_config_without_filename_should_throw() { // arrange var cfg = new MyTestConfig(); // act var result = Assert.Throws <Exception>(() => { cfg.Save(); }); // assert }
public void After_load_can_save_with_implicit_filepathname() { // arrange var cfg = new MyTestConfig(); cfg.Save(_testFilePathName); var loadedCfg = Config.Load <MyTestConfig>(_testFilePathName); // act loadedCfg.Save(); // assert Assert.Pass(); }