public void NoPrefsFileNewDataCreated() { PrefsManager <MockPrefs> serializer = new PrefsManager <MockPrefs>(); Assert.IsFalse(serializer.LoadedFromFile); MockPrefs prefs = serializer.Data; Assert.AreEqual(prefs.TestString, "Mock test string"); Assert.AreEqual(prefs.TestInt, 0); Assert.AreEqual(prefs.TestDateTime, new DateTime(0)); Assert.IsFalse(File.Exists(defaultFullPath)); }
public void SaveChangedDataTest() { PrefsManager <MockPrefs> serializer = new PrefsManager <MockPrefs>(); MockPrefs prefs = serializer.Data; prefs.TestString = "New test string"; prefs.TestInt = int.MaxValue; DateTime now = DateTime.Now; prefs.TestDateTime = now; serializer.Save(); Assert.AreEqual(prefs.TestString, "New test string"); Assert.AreEqual(prefs.TestInt, int.MaxValue); Assert.AreEqual(prefs.TestDateTime, now); if (File.Exists(defaultFullPath)) { File.Delete(defaultFullPath); } }