Exemplo n.º 1
0
        public void SettingsTracker_PersistApplyState_KeyIdentification()
        {
            DummyClass1 beforeShutdown1 = new DummyClass1() { Key = 100 };
            DummyClass1 beforeShutdown2 = new DummyClass1() { Key = 200 };
            _tracker.Configure(beforeShutdown1);
            _tracker.Configure(beforeShutdown2);
            beforeShutdown1.Property1 = 5;
            beforeShutdown1.Property2 = "first test value";
            beforeShutdown2.Property1 = 500;
            beforeShutdown2.Property2 = "second test value";

            //simulate app shutdown
            _tracker.PersistAutomaticTargets();

            //simulate app restarted
            DummyClass1 afterRestart1 = new DummyClass1() { Key = 100 };
            DummyClass1 afterRestart2 = new DummyClass1() { Key = 200 };
            SettingsTracker newSettingsTracker = new SettingsTracker();
            newSettingsTracker.Configure(afterRestart1).Apply();
            newSettingsTracker.Configure(afterRestart2).Apply();

            Assert.AreEqual(beforeShutdown1.Property1, afterRestart1.Property1);
            Assert.AreEqual(beforeShutdown1.Property2, afterRestart1.Property2);
            Assert.AreEqual(beforeShutdown2.Property1, afterRestart2.Property1);
            Assert.AreEqual(beforeShutdown2.Property2, afterRestart2.Property2);
        }
Exemplo n.º 2
0
        public void SettingsTracker_PersistApplyState_AutomaticMode()
        {
            //some object, created, configured and manupulated
            DummyClass1 beforeShutdown = new DummyClass1();
            _tracker.Configure(beforeShutdown).SetMode(PersistModes.Automatic);
            beforeShutdown.Property1 = 5;
            beforeShutdown.Property2 = "testValue";

            //simulate app shutdown
            _tracker.PersistAutomaticTargets();

            //simulate app restarted
            DummyClass1 afterRestart = new DummyClass1();
            new SettingsTracker().Configure(afterRestart).Apply();
            Assert.AreEqual(beforeShutdown.Property1, afterRestart.Property1);
            Assert.AreEqual(beforeShutdown.Property2, afterRestart.Property2);
        }