Exemplo n.º 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());
        }
Exemplo n.º 2
0
        public void GeneratedDescriptionTest()
        {
            Effect eff1 = new Effect(structure);
            Effect eff2 = new Effect(structure);
            Effect eff3 = new Effect(structure);
            Effect eff6 = new Effect(structure);

            eq11.Value       = "Valor 1";
            eq12.Value       = "Valor Opcional 2";
            eq22.Value       = "Valor 2";
            eff2.Description = "Efecto 2";
            eff3.Description = "Effecto Indirecto";
            combi2.AddEffect(eff3);
            eff6.Description = "Efecto de equivalence";
            eq11.AddEffect(eff3);
            combi2.AddEquivalenceClass(eq11);

            combi2.AddEffect(eff2);
            combi.AddEquivalenceClass(eq12);
            combi.AddEquivalenceClass(eq22);
            eq22.AddEffect(eff3);
            combi.AddEffect(eff1);

            Assert.AreEqual(combi.GeneratedDescription, "(Element Untitled 1='Valor Opcional 2' OR Element Untitled 1='Valor 1') AND (Element Untitled 2='Valor 2') THEN {CE1,Effecto Indirecto,Efecto 2}");
        }
Exemplo n.º 3
0
        public void CreateAddEffectEditTest()
        {
            EquivalenceClass equivalenceClass = new EquivalenceClass();
            Effect           effect           = new Effect();

            ce.AddEdit(EditFactory.instance.CreateAddEffectEdit(equivalenceClass, effect));
            equivalenceClass.AddEffect(effect);
            ce.End();
            ce.Undo();
            Assert.IsFalse(equivalenceClass.Effects.Contains(effect));
            ce.Redo();
            Assert.IsTrue(equivalenceClass.Effects.Contains(effect));
        }
        public void ApplyRiskLevelToChildrenTest()
        {
            effect1 = new Effect(structure);
            StateObjectManager rlm = new StateObjectManager(effect1);

            eq11.AddEffect(effect1);
            IUndoableEdit edit = rlm.ChangeState(State.FAULTY);

            Assert.AreEqual(State.FAULTY, eq11.CurrentState);
            Assert.IsFalse(dep.Combinations.Contains(combi1));

            ((CompoundEdit)edit).EndAllEdits();
            edit.Undo();
            Assert.AreNotEqual(State.FAULTY, eq11.CurrentState);
            Assert.IsTrue(dep.Combinations.Contains(combi1));
            edit.Redo();
        }
        public void IEffectsBean()
        {
            Element          elem             = new Element(to.TestCasesStruct);
            EquivalenceClass equivalenceClass = new EquivalenceClass(elem);
            Effect           effect           = new Effect(to.TestCasesStruct);

            equivalenceClass.AddEffect(effect);
            DefaultDAO dao = new DefaultDAO(to.TestCasesStruct);

            dao.Save();
            Assert.IsNotNull(dao.GetItem(elem.GetType(), elem.Id));
            Assert.IsNotNull(dao.GetItem(equivalenceClass.GetType(), equivalenceClass.Id));
            Assert.IsNotNull(dao.GetItem(effect.GetType(), effect.Id));
            EquivalenceClass eq2 = dao.GetItem(equivalenceClass.GetType(), equivalenceClass.Id) as EquivalenceClass;

#pragma warning disable PossibleNullReferenceException
            Assert.IsTrue(eq2.Effects.Contains(effect));
#pragma warning restore PossibleNullReferenceException
        }
        public void ApplyRiskLevelToChildrenTest()
        {
            effect1 = new Effect(structure);
            RiskLevelManager rlm = new RiskLevelManager(effect1);

            eq11.AddEffect(effect1);
            effect1.RiskLevel = 6;
            IUndoableEdit edit = rlm.ApplyRiskLevelToChildren();

            Assert.AreEqual(6, eq11.RiskLevel);
            Assert.AreEqual(6, combi2.RiskLevel);
            Assert.AreEqual(6, combi1.RiskLevel);
            Assert.AreEqual(6, test1.RiskLevel);
            ((CompoundEdit)edit).EndAllEdits();
            edit.Undo();
            Assert.AreNotEqual(6, eq11.RiskLevel);
            Assert.AreNotEqual(6, combi2.RiskLevel);
            Assert.AreNotEqual(6, combi1.RiskLevel);
            Assert.AreNotEqual(6, test1.RiskLevel);
            edit.Redo();
        }
        public void BasicFunctionalityLimit()
        {
            //only 3 edits permited
            queue.Limit = 3;
            CompoundEdit ce   = new CompoundEdit();
            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);
            //a compound edit
            queue.AddEdit(ce);
            //a simple edit
            queue.AddEdit(fact.CreateChangePropertyEdit(effect, "Description", "Test Description"));
            effect.Description = "Test Description";
            //another edit
            queue.AddEdit(fact.CreateRemoveEquivalenceClassEdit(elem, equivalenceClass));
            elem.RemoveEquivalenceClass(equivalenceClass);
            //the final edit
            queue.AddEdit(fact.CreateRemoveEffectEdit(equivalenceClass, effect));
            equivalenceClass.RemoveEffect(effect);
            Assert.IsTrue(queue.CanUndo());
            Assert.IsFalse(queue.CanRedo());

            queue.Undo();
            Assert.IsTrue(equivalenceClass.Effects.Contains(effect));
            Assert.IsFalse(elem.EquivalenceClasses.Contains(equivalenceClass));
            Assert.IsTrue(queue.CanUndo());
            Assert.IsTrue(queue.CanRedo());

            queue.Undo();
            Assert.IsTrue(equivalenceClass.Effects.Contains(effect));
            Assert.IsTrue(elem.EquivalenceClasses.Contains(equivalenceClass));
            Assert.IsTrue(effect.Description.Equals("Test Description"));
            Assert.IsTrue(queue.CanUndo());
            Assert.IsTrue(queue.CanRedo());

            queue.Undo();
            Assert.IsTrue(equivalenceClass.Effects.Contains(effect));
            Assert.IsTrue(elem.EquivalenceClasses.Contains(equivalenceClass));
            Assert.IsTrue(effect.Description == null);
            //the firts edit now cannot be undoed
            Assert.IsFalse(queue.CanUndo());
            Assert.IsTrue(queue.CanRedo());



            queue.Redo();
            queue.Redo();
            queue.Redo();

            Assert.IsTrue(queue.CanUndo());
            Assert.IsFalse(queue.CanRedo());
            Assert.IsTrue(effect.Description.Equals("Test Description"));
            Assert.IsFalse(equivalenceClass.Effects.Contains(effect));
        }