示例#1
0
        public void BasicFunctionality()
        {
            IEditFactory fact = EditFactory.instance;
            Element      elem = new Element();

            EquivalenceClass equivalenceClass = new EquivalenceClass();
            Effect           effect           = new Effect();

            ce.AddEdit(fact.CreateAddEquivalenceClassEdit(elem, equivalenceClass));
            elem.AddEquivalenceClass(equivalenceClass);
            ce.AddEdit(fact.CreateAddEffectEdit(equivalenceClass, effect));
            equivalenceClass.AddEffect(effect);
            Assert.IsFalse(ce.CanUndo());
            Assert.IsFalse(ce.CanRedo());
            //finalize all edits so it can be undoed
            ce.EndAllEdits();
            Assert.IsTrue(ce.CanUndo());
            Assert.IsFalse(ce.CanRedo());
            ce.Undo();
            Assert.IsFalse(equivalenceClass.Effects.Contains(effect));
            Assert.IsFalse(elem.EquivalenceClasses.Contains(equivalenceClass));
            ce.Redo();
            Assert.IsTrue(equivalenceClass.Effects.Contains(effect));
            Assert.IsTrue(elem.EquivalenceClasses.Contains(equivalenceClass));

            ce.Die();
            Assert.IsFalse(ce.CanUndo());
            Assert.IsFalse(ce.CanRedo());
        }
示例#2
0
        public void CreateChangePropertyEditTest()
        {
            Element element = new Element();
            string  name2   = "Name 2";

            element.Name = "Name 1";
            ce.AddEdit(EditFactory.instance.CreateChangePropertyEdit(element, "Name", name2));
            element.Name = name2;
            ce.End();
            ce.Undo();
            Assert.AreEqual(element.Name, "Name 1");
            ce.Redo();
            Assert.AreEqual(element.Name, "Name 2");
        }