Ejemplo n.º 1
0
        public void IsSavedTest()
        {
            var manager = new MockSettingsManager();

            // IsSaved should be true because it's persistent (all values are default)
            Assert.IsTrue(manager.IsSaved);

            // Change values
            manager.DateTime = DateTime.Now;

            // IsSaved should be false because a value was changed
            Assert.IsFalse(manager.IsSaved);

            // Save
            manager.Save();

            // IsSaved should be true because the settings are saved
            Assert.IsTrue(manager.IsSaved);

            // Change values
            manager.Int = 43;

            // IsSaved should be false because a value was changed
            Assert.IsFalse(manager.IsSaved);

            // Load
            manager.Load();

            // IsSaved should be true because the settings are saved
            Assert.IsTrue(manager.IsSaved);

            // Change values
            manager.Class = new MockClass();

            // IsSaved should be false because a value was changed
            Assert.IsFalse(manager.IsSaved);

            // Reset
            manager.Reset();

            // IsSaved should be false because it's not persistent anymore
            Assert.IsFalse(manager.IsSaved);
        }
Ejemplo n.º 2
0
        public void SaveChangesTest()
        {
            var manager = new MockSettingsManager();

            // Change some values
            manager.Int    = 13;
            manager.Double = 3.14;

            // Save
            manager.Save();

            // Re-create
            manager = new MockSettingsManager();

            // Load
            manager.Load();

            // Check values
            Assert.AreEqual(13, manager.Int);
            Assert.AreEqual(3.14, manager.Double);
            Assert.AreEqual("Hello World", manager.Str);
        }