Exemple #1
0
        public void ApplicationClosingEvent_NotSaveWhenApplicationClosing_ShouldNotAutoSaveWhenAppClosing()
        {
            var config = Utils.CreateConfig();
            var @event = new MockApplicationClosingEvent();

            config.Settings.ApplicationClosingEvent    = @event;
            config.Settings.SaveWhenApplicationClosing = false;
            config.Register <AnotherTestConfig>();
            @event.SimulateEvent();
            var savedFilePath = Path.Combine(config.Settings.ConfigDir, "anotherConfig.json");

            Assert.IsFalse(File.Exists(savedFilePath));
            Utils.ReleaseConfig(config);
        }
Exemple #2
0
        public void ApplicationClosingEvent_SaveWhenApplicationClosing_ShouldAutoSaveWhenAppClosing()
        {
            var config = Utils.CreateConfig();
            var @event = new MockApplicationClosingEvent();

            config.Settings.ApplicationClosingEvent = @event;
            config.Register <AnotherTestConfig>();
            @event.SimulateEvent();
            var savedFilePath = Path.Combine(config.Settings.ConfigDir, "anotherConfig.json");

            Assert.IsTrue(File.Exists(savedFilePath));
            Assert.Greater(File.ReadAllText(savedFilePath).Length, 0);
            Utils.ReleaseConfig(config);
        }