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

            // Save
            manager.Save();
            Assert.IsTrue(File.Exists(manager.FullFilePath));
        }
Ejemplo n.º 2
0
        public void DeleteTest()
        {
            var manager = new MockSettingsManager();

            // Save
            manager.Save();

            // Delete
            manager.Delete();
            Assert.IsFalse(File.Exists(manager.FullFilePath));
        }
Ejemplo n.º 3
0
        public void DeleteWithDirTest()
        {
            var manager = new MockSettingsManager();

            // Save
            manager.Save();

            // Delete
            manager.Delete(true);
            Assert.IsFalse(File.Exists(manager.FullFilePath));
            Assert.IsFalse(Directory.Exists(manager.FullDirectoryPath));
        }
Ejemplo n.º 4
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.º 5
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);
        }
Ejemplo n.º 6
0
        public void SaveUpgradeLoadTest()
        {
            var oldManager = new MockSettingsManager();

            // Set some values
            oldManager.Double     = 66.55;
            oldManager.Class      = new MockClass();
            oldManager.Class.Long = 132;

            // Save
            oldManager.Save();

            // Upgrade
            var newManager = new MockSettingsManagerNewer();

            // Load
            newManager.Load();

            // Check values
            Assert.AreEqual(66.55, newManager.Double);
            Assert.IsNotNull(newManager.Class);
            Assert.AreEqual(132, newManager.Class.Long);
            Assert.AreEqual('Q', newManager.Char);
        }