public void CreateDerivatedScenario_Bug1552_Test() { var scenarioCible1 = new Scenario() { NatureCode = KnownScenarioNatures.Target, }; var actionEScenario1 = new KAction { Scenario = scenarioCible1, BuildDuration = 1, Reduced = new KActionReduced() { ActionTypeCode = KnownActionCategoryTypes.E, ReductionRatio = .1, }, WBS = "1", }; var newScenario = ScenarioCloneManager.CreateDerivatedScenario(null, scenarioCible1, KnownScenarioNatures.Target, false, 2); var actionEScenario2 = newScenario.Actions.First(); Assert.IsTrue(actionEScenario2.IsReduced); Assert.AreEqual(KnownActionCategoryTypes.E, actionEScenario2.Reduced.ActionTypeCode); }
public void CloneActionFromInitialToTargetTest() { var catI = new ActionCategoryStandard { ActionTypeCode = KnownActionCategoryTypes.I }; var catE = new ActionCategoryStandard { ActionTypeCode = KnownActionCategoryTypes.E }; var catS = new ActionCategoryStandard { ActionTypeCode = KnownActionCategoryTypes.S }; var actionNonPretypee = new KAction() { BuildDuration = 30, }; var actionPretypeeI = new KAction() { BuildDuration = 30, Category = catI }; var actionPretypeeE = new KAction() { BuildDuration = 30, Category = catE }; var actionPretypeeS = new KAction() { BuildDuration = 30, Category = catS }; // En mode initial to target, on n'est pas sensé avoir de partie réduite à la base // Le prétype par la catégorie uniquement s'applique var clone = ScenarioCloneManager.CloneAction(actionNonPretypee, ScenarioCloneManager.ActionCloneBehavior.InitialToTarget); AssertClonedAction(clone, 30, true, 0, 30, KnownActionCategoryTypes.I); clone = ScenarioCloneManager.CloneAction(actionPretypeeI, ScenarioCloneManager.ActionCloneBehavior.InitialToTarget); AssertClonedAction(clone, 30, true, 0, 30, KnownActionCategoryTypes.I); clone = ScenarioCloneManager.CloneAction(actionPretypeeE, ScenarioCloneManager.ActionCloneBehavior.InitialToTarget); AssertClonedAction(clone, 30, true, 0, 30, KnownActionCategoryTypes.E); clone = ScenarioCloneManager.CloneAction(actionPretypeeS, ScenarioCloneManager.ActionCloneBehavior.InitialToTarget); AssertClonedAction(clone, 0, true, 1, 30, KnownActionCategoryTypes.S); }
public void CloneActionFromTargetToRealizedTest() { // Target to realized : pour I et E, on copie la partie Realized var action = new KAction { BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.I, ReductionRatio = .1, OriginalBuildDuration = 30, }, }; var clone = ScenarioCloneManager.CloneAction(action, ScenarioCloneManager.ActionCloneBehavior.TargetToRealized); AssertClonedAction(clone, 27, true, 0d, 27, KnownActionCategoryTypes.I); action = new KAction { BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.E, ReductionRatio = .1, OriginalBuildDuration = 30, }, }; clone = ScenarioCloneManager.CloneAction(action, ScenarioCloneManager.ActionCloneBehavior.TargetToRealized); AssertClonedAction(clone, 27, true, 0d, 27, KnownActionCategoryTypes.E); // Une tâche S doit être supprimée action = new KAction { BuildDuration = 0, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.S, ReductionRatio = 1, OriginalBuildDuration = 30, }, }; clone = ScenarioCloneManager.CloneAction(action, ScenarioCloneManager.ActionCloneBehavior.TargetToRealized); AssertClonedActionNotReduced(clone, 0); }
public void CreateDerivatedScenarioTest2() { var scenarioCible1 = new Scenario() { NatureCode = KnownScenarioNatures.Initial, }; var cat = new ActionCategoryProject { }; var catI = new ActionCategoryProject { ActionTypeCode = KnownActionCategoryTypes.I }; var catE = new ActionCategoryProject { ActionTypeCode = KnownActionCategoryTypes.E }; var catS = new ActionCategoryProject { ActionTypeCode = KnownActionCategoryTypes.S }; var a = new KAction { Scenario = scenarioCible1, Category = cat, WBS = "1" }; var aI = new KAction { Scenario = scenarioCible1, Category = catI, WBS = "2" }; var aE = new KAction { Scenario = scenarioCible1, Category = catE, WBS = "3" }; var aS = new KAction { Scenario = scenarioCible1, Category = catS, WBS = "4" }; var newScenario = ScenarioCloneManager.CreateDerivatedScenario(null, scenarioCible1, KnownScenarioNatures.Target, false, 2); Assert.AreEqual(KnownActionCategoryTypes.I, newScenario.Actions[0].Reduced.ActionTypeCode); Assert.AreEqual(KnownActionCategoryTypes.I, newScenario.Actions[1].Reduced.ActionTypeCode); Assert.AreEqual(KnownActionCategoryTypes.E, newScenario.Actions[2].Reduced.ActionTypeCode); Assert.AreEqual(KnownActionCategoryTypes.S, newScenario.Actions[3].Reduced.ActionTypeCode); }
public void CloneActionCascadeTest() { var catI = new ActionCategoryStandard { ActionTypeCode = KnownActionCategoryTypes.I }; var catE = new ActionCategoryStandard { ActionTypeCode = KnownActionCategoryTypes.E }; var catS = new ActionCategoryStandard { ActionTypeCode = KnownActionCategoryTypes.S }; // En mode Cascade, on applique le type de Reduced si la tâche est réduite, sinon on applique le type de ActioNCategory, tout en conservant la réduc var action = new KAction { BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.I, ReductionRatio = .1, OriginalBuildDuration = 30, }, OriginalActionId = -1, // simule un original en dehors du scénario Category = catE, }; var clone = ScenarioCloneManager.CloneAction(action, ScenarioCloneManager.ActionCloneBehavior.Cascade); AssertClonedAction(clone, 27, true, 0, 27, KnownActionCategoryTypes.I); action = new KAction { BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.I, ReductionRatio = .1, OriginalBuildDuration = 30, }, Category = catI, }; clone = ScenarioCloneManager.CloneAction(action, ScenarioCloneManager.ActionCloneBehavior.Cascade); AssertClonedAction(clone, 27, true, 0, 27, KnownActionCategoryTypes.I); action = new KAction { BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.I, ReductionRatio = .1, OriginalBuildDuration = 30, }, Category = catE, }; clone = ScenarioCloneManager.CloneAction(action, ScenarioCloneManager.ActionCloneBehavior.Cascade); AssertClonedAction(clone, 27, true, 0, 27, KnownActionCategoryTypes.I); action = new KAction { BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.I, ReductionRatio = .1, OriginalBuildDuration = 30, }, Category = catS, }; clone = ScenarioCloneManager.CloneAction(action, ScenarioCloneManager.ActionCloneBehavior.Cascade); AssertClonedAction(clone, 27, true, 0, 27, KnownActionCategoryTypes.I); action = new KAction { BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.E, ReductionRatio = .1, OriginalBuildDuration = 30, }, Category = catE, }; clone = ScenarioCloneManager.CloneAction(action, ScenarioCloneManager.ActionCloneBehavior.Cascade); AssertClonedAction(clone, 27, true, 0, 27, KnownActionCategoryTypes.E); action = new KAction { BuildDuration = 0, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.S, ReductionRatio = 1, OriginalBuildDuration = 30, }, Category = catS, }; clone = ScenarioCloneManager.CloneAction(action, ScenarioCloneManager.ActionCloneBehavior.Cascade); AssertClonedAction(clone, 0, true, 1, 0, KnownActionCategoryTypes.S); }
public void CloneActionFromTargetToTargetTest() { var scenario = new Scenario() { }; var catI = new ActionCategoryStandard { ActionTypeCode = KnownActionCategoryTypes.I }; var catE = new ActionCategoryStandard { ActionTypeCode = KnownActionCategoryTypes.E }; var catS = new ActionCategoryStandard { ActionTypeCode = KnownActionCategoryTypes.S }; var actionIGrandParent = new KAction { BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.I, ReductionRatio = .1, OriginalBuildDuration = 30, }, OriginalActionId = -1, // simule un original en dehors du scénario Category = catE, }; // Tache I provenant du grand parent, on n'applique pas le prétype mais on applique la réduc var clone = ScenarioCloneManager.CloneAction(actionIGrandParent, ScenarioCloneManager.ActionCloneBehavior.TargetToTarget); AssertClonedAction(clone, 27, true, 0, 27, KnownActionCategoryTypes.I); var actionIparentCatI = new KAction { BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.I, ReductionRatio = .1, OriginalBuildDuration = 30, }, Category = catI, }; // Tache I provenant du parent, on applique le prétypage et la réduc s'il y en a clone = ScenarioCloneManager.CloneAction(actionIparentCatI, ScenarioCloneManager.ActionCloneBehavior.TargetToTarget); AssertClonedAction(clone, 27, true, 0, 27, KnownActionCategoryTypes.I); var actionIparentCatE = new KAction { BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.I, ReductionRatio = .1, OriginalBuildDuration = 30, }, Category = catE, }; // Tache I provenant du parent, on applique le prétypage et la réduc s'il y en a clone = ScenarioCloneManager.CloneAction(actionIparentCatE, ScenarioCloneManager.ActionCloneBehavior.TargetToTarget); AssertClonedAction(clone, 27, true, 0, 27, KnownActionCategoryTypes.E); var actionIparentCatS = new KAction { BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.I, ReductionRatio = .1, OriginalBuildDuration = 30, }, Category = catS, }; // Tache I provenant du parent, on applique le prétypage et la réduc s'il y en a clone = ScenarioCloneManager.CloneAction(actionIparentCatS, ScenarioCloneManager.ActionCloneBehavior.TargetToTarget); AssertClonedAction(clone, 0, true, 1, 27, KnownActionCategoryTypes.S); var actionE = new KAction { BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.E, ReductionRatio = .1, OriginalBuildDuration = 30, }, Category = catI, }; // Tâche E, on conserve E et on applique la réduc clone = ScenarioCloneManager.CloneAction(actionE, ScenarioCloneManager.ActionCloneBehavior.TargetToTarget); AssertClonedAction(clone, 27, true, 0, 27, KnownActionCategoryTypes.E); var actionS = new KAction { BuildDuration = 0, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.S, ReductionRatio = 1, } }; // Tâche S, on supprime l'action clone = ScenarioCloneManager.CloneAction(actionS, ScenarioCloneManager.ActionCloneBehavior.TargetToTarget); AssertClonedAction(clone, 0, true, 1, 0, KnownActionCategoryTypes.S); var scenarioSolutionNOK = new Scenario(); scenarioSolutionNOK.Solutions.Add(new Solution() { SolutionDescription = "NOK", Approved = false, }); var actionENOK = new KAction { BuildDuration = 30, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.E, ReductionRatio = .1, OriginalBuildDuration = 30, Solution = "NOK", }, Category = catS, Scenario = scenarioSolutionNOK, }; // Tâche NOK, on ne prend pas en compte le prétypage ni l'action type du reduced, on la laisse I clone = ScenarioCloneManager.CloneAction(actionENOK, ScenarioCloneManager.ActionCloneBehavior.TargetToTarget); AssertClonedAction(clone, 30, true, 0, 30, KnownActionCategoryTypes.I); }
public void CreateDerivatedScenario_TargetToTarget_Test() { var scenario = new Scenario { NatureCode = KnownScenarioNatures.Target, }; var catI = new ActionCategoryStandard { ActionTypeCode = KnownActionCategoryTypes.I }; var catE = new ActionCategoryStandard { ActionTypeCode = KnownActionCategoryTypes.E }; var catS = new ActionCategoryStandard { ActionTypeCode = KnownActionCategoryTypes.S }; var actionIGrandParent = new KAction { Scenario = scenario, Duration = 27, BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.I, ReductionRatio = .1, OriginalBuildDuration = 30, }, OriginalActionId = -1, // simule un original en dehors du scénario Category = catE, WBS = "1", }; var actionIparentCatI = new KAction { Scenario = scenario, Duration = 27, BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.I, ReductionRatio = .1, OriginalBuildDuration = 30, }, Category = catI, WBS = "2", }; var actionIparentCatE = new KAction { Scenario = scenario, Duration = 27, BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.I, ReductionRatio = .1, OriginalBuildDuration = 30, }, Category = catE, WBS = "3", }; var actionIparentCatS = new KAction { Label = "actionIparentCatS", Scenario = scenario, Duration = 27, BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.I, ReductionRatio = .1, OriginalBuildDuration = 30, }, Category = catS, WBS = "4", }; var actionE = new KAction { Scenario = scenario, Duration = 27, BuildDuration = 27, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.E, ReductionRatio = .1, OriginalBuildDuration = 30, }, Category = catI, WBS = "5", }; var actionS = new KAction { Label = "actionS", Scenario = scenario, Duration = 0, BuildDuration = 0, Reduced = new KActionReduced { ActionTypeCode = KnownActionCategoryTypes.S, ReductionRatio = 1, }, WBS = "6", }; var newScenario = ScenarioCloneManager.CreateDerivatedScenario(null, scenario, KnownScenarioNatures.Target, false, 2); // Tache I provenant du grand parent, on n'applique pas le prétype mais on applique la réduc var cloneIGrandParent = newScenario.Actions[0]; AssertClonedAction(cloneIGrandParent, 27, true, 0, 27, KnownActionCategoryTypes.I); // Tache I provenant du parent, on applique le prétypage et la réduc s'il y en a : prétypage I var cloneIparentCatI = newScenario.Actions[1]; AssertClonedAction(cloneIparentCatI, 27, true, 0, 27, KnownActionCategoryTypes.I); // Tache I provenant du parent, on applique le prétypage et la réduc s'il y en a : prétypage E var cloneIparentCatE = newScenario.Actions[2]; AssertClonedAction(cloneIparentCatE, 27, true, 0, 27, KnownActionCategoryTypes.E); // Tache I provenant du parent, on applique le prétypage et la réduc s'il y en a : prétypage S => Suppression var cloneIparentCatS = newScenario.Actions[0]; Assert.IsTrue(!newScenario.Actions.Any(a => a.Label == actionIparentCatS.Label)); // Tâche E, on conserve E et on applique la réduc var cloneE = newScenario.Actions[3]; AssertClonedAction(cloneE, 27, true, 0, 27, KnownActionCategoryTypes.E); // Tâche S, on supprime l'action var cloneS = newScenario.Actions[0]; Assert.IsTrue(!newScenario.Actions.Any(a => a.Label == actionS.Label)); }