Ejemplo n.º 1
0
 public void TestDoAction()
 {
     var actionStack = new TransactionalActionStack(5);
     using (new DirtiableManager(actionStack))
     {
         var dirtiable = new SimpleDirtiable();
         var action = new SimpleDirtiableActionItem(dirtiable.Yield());
         actionStack.Add(action);
         Assert.AreEqual(true, dirtiable.IsDirty);
     }
 }
Ejemplo n.º 2
0
 public void TestEvent()
 {
     var actionStack = new TransactionalActionStack(5);
     int eventCount = 0;
     using (new DirtiableManager(actionStack))
     {
         var dirtiable = new SimpleDirtiable();
         dirtiable.DirtinessUpdated += (sender, e) =>
         {
             Assert.AreEqual(eventCount != 0, e.OldValue);
             Assert.AreEqual(true, e.NewValue);
             eventCount++;
         };
         Assert.AreEqual(false, dirtiable.IsDirty);
         actionStack.Add(new SimpleDirtiableActionItem(dirtiable.Yield()));
         Assert.AreEqual(true, dirtiable.IsDirty);
         actionStack.Add(new SimpleDirtiableActionItem(dirtiable.Yield()));
         Assert.AreEqual(true, dirtiable.IsDirty);
         Assert.AreEqual(2, eventCount);
     }
 }
Ejemplo n.º 3
0
 public void TestDoAndSave()
 {
     var actionStack = new TransactionalActionStack(5);
     using (var manager = new DirtiableManager(actionStack))
     {
         var dirtiable = new SimpleDirtiable();
         var action = new SimpleDirtiableActionItem(dirtiable.Yield());
         actionStack.Add(action);
         Assert.AreEqual(true, dirtiable.IsDirty);
         actionStack.CreateSavePoint(true);
         manager.NotifySave();
         Assert.AreEqual(false, dirtiable.IsDirty);
     }
 }
Ejemplo n.º 4
0
        public void TestRedo()
        {
            var actionStack = new TransactionalActionStack(5);

            using (new DirtiableManager(actionStack))
            {
                var dirtiable = new SimpleDirtiable();
                var action    = new SimpleDirtiableActionItem(dirtiable.Yield());
                actionStack.Add(action);
                Assert.AreEqual(true, dirtiable.IsDirty);
                actionStack.Undo();
                actionStack.Redo();
                Assert.AreEqual(true, dirtiable.IsDirty);
            }
        }
Ejemplo n.º 5
0
        public void TestDoAndSave()
        {
            var actionStack = new TransactionalActionStack(5);

            using (var manager = new DirtiableManager(actionStack))
            {
                var dirtiable = new SimpleDirtiable();
                var action    = new SimpleDirtiableActionItem(dirtiable.Yield());
                actionStack.Add(action);
                Assert.AreEqual(true, dirtiable.IsDirty);
                actionStack.CreateSavePoint(true);
                manager.NotifySave();
                Assert.AreEqual(false, dirtiable.IsDirty);
            }
        }