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 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); }