public void SaveRestoreTest() { DataPersistor persistor = new DataPersistor(); persistor.FullPath = Path.Combine(Path.GetTempPath(), "test1.json"); persistor.SaveDataMethod = this.SaveMethod; persistor.RestoreDataMethod = this.RestoreMethod; this.Data["value1"] = "ORIGINAL DATA1"; this.Data["value2"] = "ORIGINAL DATA2"; persistor.Save(); // change some values this.Data["value1"] = "New DATA1"; this.Data["value2"] = "New DATA2"; persistor.Restore(); // check for restored values Assert.AreEqual("ORIGINAL DATA1", this.Data["value1"]); Assert.AreEqual("ORIGINAL DATA2", this.Data["value2"]); File.Delete(persistor.FullPath); }
public void MultipleSaveTest() { DataPersistor persistor = new DataPersistor(); persistor.FullPath = Path.Combine(Path.GetTempPath(), "test2.json"); persistor.SaveDataMethod = this.SaveMethod; persistor.RestoreDataMethod = this.RestoreMethod; this.Data["value1"] = "ORIGINAL DATA1"; this.Data["value2"] = "ORIGINAL DATA2"; persistor.Save(); persistor.Restore(); this.Data["value3"] = "ADDED DATA3"; persistor.Save(); persistor.Restore(); this.Data["value2"] = "CHANGED DATA2"; persistor.Save(); persistor.Restore(); // check for restored values Assert.AreEqual("ORIGINAL DATA1", this.Data["value1"]); Assert.AreEqual("CHANGED DATA2", this.Data["value2"]); Assert.AreEqual("ADDED DATA3", this.Data["value3"]); File.Delete(persistor.FullPath); }