private IUndoableEdit MergeEffects(IList <Combination> combinationsToMerge) { CompoundEdit ce = new CompoundEdit(); foreach (Combination combi in combinationsToMerge) { foreach (Effect effect in combi.Effects) { if (!combination.Effects.Contains(effect)) { ce.AddEdit(EditFactory.instance.CreateAddEffectEdit(combination, effect)); combination.AddEffect(effect); } } } foreach (Combination combi in combinationsToMerge) { foreach (Effect effect in combi.Effects) { if (!combi.Effects.Contains(effect)) { ce.AddEdit(EditFactory.instance.CreateAddEffectEdit(combi, effect)); combi.AddEffect(effect); } //update risk level RiskLevelManager rlm = new RiskLevelManager(effect); ce.AddEdit(rlm.ApplyRiskLevelToChildren()); //update state StateObjectManager som = new StateObjectManager(effect); ce.AddEdit(som.ApplyStateToChildren()); } } return(ce); }
public IUndoableEdit ApplyStateToChildren() { if (stateObject == null) { return(null); } CompoundEdit ce = new CompoundEdit(); if (stateObject.GetChildrenObjectStates() == null) { return(ce); } foreach (IStateObject o in stateObject.GetChildrenObjectStates()) { StateObjectManager rlc = new StateObjectManager(o); ce.AddEdit(rlc.ChangeState(stateObject.CurrentState)); } return(ce); }
public IUndoableEdit AddEquivalenceClass(EquivalenceClass equivalenceClass) { if (testCase == null) { throw new Exception("The test case cannot be null"); } CompoundEdit ce = new CompoundEdit(); ce.AddEdit(EditFactory.instance.CreateAddEquivalenceClassEdit(testCase, equivalenceClass)); testCase.AddEquivalenceClass(equivalenceClass); RiskLevelManager rlc = new RiskLevelManager(equivalenceClass); ce.AddEdit(rlc.ApplyRiskLevelToChildren()); StateObjectManager som = new StateObjectManager(equivalenceClass); ce.AddEdit(som.ApplyStateToChildren()); return(ce); }
public IUndoableEdit ChangeState(State newState) { CompoundEdit ce = new CompoundEdit(); if ((stateObject == null)) { return(ce); } //check if the new state can apply to the statebean if (stateObject.GetParentObjectStates() != null) { foreach (IStateObject parentStateObject in stateObject.GetParentObjectStates()) { if (CompareState(parentStateObject.CurrentState, newState) < 0) { throw new Exception("The state cannot change, contains a greater state as a parent"); } } } if (stateObject.GetChildrenObjectStates() == null) { return(ce); } foreach (IStateObject o in stateObject.GetChildrenObjectStates()) { if (o is Combination && stateObject is EquivalenceClass && newState != State.POSITIVE) { ce.AddEdit(PropagateStateChangeInCombination((Combination)o, (EquivalenceClass)stateObject)); } else { StateObjectManager rlc = new StateObjectManager(o); ce.AddEdit(rlc.ChangeState(newState)); } } ce.AddEdit(EditFactory.instance.CreateChangeStateEdit(stateObject, newState)); stateObject.CurrentState = newState; return(ce); }
public IUndoableEdit ApplyState(IStateObject stateObject, State newState) { StateObjectManager sto = new StateObjectManager(stateObject); return(sto.ChangeState(newState)); }