コード例 #1
0
        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);
        }
コード例 #2
0
        public void ConvertToNewProjectTest()
        {
            var std = new ActionCategoryStandard()
            {
                ActionTypeCode  = "ABCD",
                ActionValueCode = "EFGH",
                Color           = "#AB",
                Label           = "Label",

                ActionCategoryId     = 10,
                CreatedByUserId      = 1,
                CreationDate         = DateTime.Now,
                ModifiedByUserId     = 2,
                LastModificationDate = DateTime.Now,
            };

            var project = (ActionCategoryProject)ReferentialsFactory.CopyToNewProject(std);

            Assert.AreEqual(std.ActionTypeCode, project.ActionTypeCode);
            Assert.AreEqual(std.ActionValueCode, project.ActionValueCode);
            Assert.AreEqual(std.Color, project.Color);
            Assert.AreEqual(std.Label, project.Label);

            Assert.AreEqual(default(int), project.ActionCategoryId);
            Assert.AreEqual(default(int), project.CreatedByUserId);
            Assert.AreEqual(default(int), project.ModifiedByUserId);
            Assert.AreEqual(default(DateTime), project.CreationDate);
            Assert.AreEqual(default(DateTime), project.LastModificationDate);

            Assert.IsNull(project.Project);
            Assert.AreEqual(default(int), project.ProjectId);

            Assert.IsNotNull(ReferentialsFactory.CopyToNewProject(new Ref2Standard()));
            Assert.IsNotNull(ReferentialsFactory.CopyToNewProject(new Ref4Standard()));
            Assert.IsNotNull(ReferentialsFactory.CopyToNewProject(new Ref3Standard()));
            Assert.IsNotNull(ReferentialsFactory.CopyToNewProject(new EquipmentStandard()));
            Assert.IsNotNull(ReferentialsFactory.CopyToNewProject(new OperatorStandard()));
            Assert.IsNotNull(ReferentialsFactory.CopyToNewProject(new Ref1Standard()));
        }
コード例 #3
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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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));
        }