示例#1
0
            public void Set_Two_Actions_Enabled_AssignTo()
            {
                IPlanElementUtils pUtils     = new PlanElementUtils();
                string            modId      = ObjectId.GenerateNewId().ToString();
                ObjectId          assingtoID = ObjectId.GenerateNewId();

                AD.Program prog = new AD.Program
                {
                    AssignToId = assingtoID.ToString(),
                    Modules    = new List <AD.Module>
                    {
                        new AD.Module
                        {
                            Id      = modId,
                            Actions = new List <AD.Actions>
                            {
                                new AD.Actions
                                {
                                    Enabled = true
                                },
                                new AD.Actions
                                {
                                    Enabled = true
                                }
                            }
                        }
                    }
                };

                pUtils.SetElementEnabledState(modId, prog);
                Assert.AreEqual(assingtoID.ToString(), prog.Modules[0].Actions[0].AssignToId);
                Assert.AreEqual(assingtoID.ToString(), prog.Modules[0].Actions[1].AssignToId);
            }
示例#2
0
            public void Set_One_Action_Enabled_AssignDate()
            {
                IPlanElementUtils pUtils = new PlanElementUtils();
                string            modId  = ObjectId.GenerateNewId().ToString();

                AD.Program prog = new AD.Program
                {
                    Modules = new List <AD.Module>
                    {
                        new AD.Module
                        {
                            Id      = modId,
                            Actions = new List <AD.Actions>
                            {
                                new AD.Actions
                                {
                                    Enabled = true
                                },
                                new AD.Actions
                                {
                                    Enabled = false
                                }
                            }
                        }
                    }
                };

                pUtils.SetElementEnabledState(modId, prog);
                Assert.AreEqual(DateTime.UtcNow.Date, ((DateTime)prog.Modules[0].Actions[0].AssignDate).Date);
            }
示例#3
0
            public void Set_One_Action_Enabled()
            {
                IPlanElementUtils pUtils = new PlanElementUtils();
                string            modId  = ObjectId.GenerateNewId().ToString();

                AD.Program prog = new AD.Program
                {
                    Modules = new List <AD.Module>
                    {
                        new AD.Module
                        {
                            Id      = modId,
                            Actions = new List <AD.Actions>
                            {
                                new AD.Actions
                                {
                                    Enabled = true
                                },
                                new AD.Actions
                                {
                                    Enabled = false
                                }
                            }
                        }
                    }
                };

                pUtils.SetElementEnabledState(modId, prog);
                Assert.IsNotNull(prog.Modules[0].Actions[0].AssignById);
            }
示例#4
0
            public void SetInitialValuesTest_disabled()
            {
                IPlanElementUtils pUtils = new PlanElementUtils();
                var pe = new AD.PlanElement {
                    Enabled = false
                };
                var id = "999999999999999999999999";

                pUtils.SetInitialValues(id, pe);

                Assert.AreNotEqual(pe.AssignDate, null);
            }
示例#5
0
            public void InitializePlanElementSettings_false()
            {
                IPlanElementUtils pUtils = new PlanElementUtils();

                AD.PlanElement pe = new AD.PlanElement {
                    Enabled = false
                };
                pUtils.InitializePlanElementSettings(pe, pe, new AD.Program {
                    AssignToId = "999999999999999999999999"
                });
                Assert.AreNotEqual(pe.AssignDate, null);
            }
示例#6
0
            public void Get_Assigned_Date()
            {
                DateTime          control = DateTime.UtcNow.Date;
                IPlanElementUtils peUtil  = new PlanElementUtils {
                };

                AD.Module  mod  = new AD.Module();
                AD.Program prog = new AD.Program();

                peUtil.SetInitialProperties("123456789012345678901234", mod, false);

                Assert.AreEqual(DateTime.UtcNow.Date, ((DateTime)mod.AssignDate).Date);
            }
示例#7
0
            public void Get_Assigned_To()
            {
                ObjectId?         assignedTO = new ObjectId();
                IPlanElementUtils peUtil     = new PlanElementUtils {
                };

                AD.Module  mod  = new AD.Module();
                AD.Program prog = new AD.Program {
                    AssignToId = assignedTO.ToString()
                };

                peUtil.SetInitialProperties(assignedTO.ToString(), mod, false);

                Assert.AreEqual(assignedTO.ToString(), mod.AssignToId);
            }
示例#8
0
            public void Get_Assigned_To_Null()
            {
                string            assignedTO = null;
                IPlanElementUtils peUtil     = new PlanElementUtils {
                };

                AD.Module  mod  = new AD.Module();
                AD.Program prog = new AD.Program {
                    AssignToId = assignedTO
                };

                peUtil.SetInitialProperties(assignedTO, mod, false);

                Assert.AreEqual(assignedTO, mod.AssignToId);
            }
示例#9
0
            public void Set_Assigned_Date_Null()
            {
                string            assignedTO = null;
                IPlanElementUtils peUtil     = new PlanElementUtils {
                };

                AD.Module  mod  = new AD.Module();
                AD.Program prog = new AD.Program {
                    AssignToId = assignedTO
                };

                peUtil.SetInitialProperties(assignedTO, mod, false);

                Assert.AreEqual(DateTime.UtcNow.Date, ((DateTime)mod.AssignDate).Date);
            }
示例#10
0
            public void Clone_Action_With_AssignTo()
            {
                ObjectId          control = ObjectId.GenerateNewId();
                IPlanElementUtils peUtil  = new PlanElementUtils {
                };

                AD.Actions action = new AD.Actions {
                    ElementState = 1, AssignToId = control.ToString()
                };
                peUtil.CloneAction(action);

                string sample = action.AssignToId;

                Assert.AreEqual(control.ToString(), sample);
            }
示例#11
0
            public void Clone_With_StateChangeDate()
            {
                DateTime          control = DateTime.UtcNow.Date;
                IPlanElementUtils peUtil  = new PlanElementUtils {
                };

                AD.Program program = new AD.Program {
                    ElementState = 1, StateUpdatedOn = control
                };
                peUtil.CloneProgram(program);

                DateTime sample = ((DateTime)program.StateUpdatedOn).Date;

                Assert.AreEqual(control, sample);
            }
示例#12
0
            public void Set_Assigned_On_With_Previous_Complete()
            {
                IPlanElementUtils peUtil = new PlanElementUtils {
                };
                var mods = new List <AD.Module> {
                    new AD.Module {
                        Id = "123456789012345678901234", Completed = true
                    }
                };

                AD.Module mod = new DTO.Module {
                    Previous = "123456789012345678901234"
                };
                peUtil.SetEnabledState(mods, mod, "123456789012345612341234", true);
                Assert.AreEqual(DateTime.UtcNow.Date, ((DateTime)mod.AssignDate).Date);
            }
示例#13
0
            public void Set_Assigned_On_With_Previous_Not_Complete()
            {
                IPlanElementUtils peUtil = new PlanElementUtils {
                };
                var mods = new List <AD.Module> {
                    new AD.Module {
                        Id = "123456789012345678901234", Completed = false
                    }
                };

                AD.Module mod = new DTO.Module {
                    Previous = "123456789012345678901234"
                };
                peUtil.SetEnabledState(mods, mod, "123456789012345612341234", true);
                Assert.IsNull(mod.AssignDate);
            }
示例#14
0
        public void CloneRepeatActionTest()
        {
            IPlanElementUtils pUtils = new PlanElementUtils();

            var actionId       = ObjectId.GenerateNewId().ToString();
            var step1Id        = ObjectId.GenerateNewId().ToString();
            var step2Id        = ObjectId.GenerateNewId().ToString();
            var selectedRespId = ObjectId.GenerateNewId().ToString();

            var action = SampleFactory.CreateCloneAction(actionId, step1Id, step2Id, selectedRespId);

            var newAction = pUtils.CloneRepeatAction(action, ObjectId.GenerateNewId().ToString());

            Assert.AreNotEqual(action.Id, newAction.Id);
            Assert.AreEqual(action.ElementState, newAction.ElementState);
        }
示例#15
0
            public void Set_Status_As_Enabled_AssignDate()
            {
                IPlanElementUtils pUtils = new PlanElementUtils();

                var mods = new List <AD.PlanElement>
                {
                    new AD.PlanElement {
                        Id = "000006789012345678901234", Completed = true
                    },
                    new AD.PlanElement {
                        Previous = "000006789012345678901234"
                    }
                };

                pUtils.SetEnabledStatusByPrevious(mods, "123456789012345678901234", true);
                Assert.IsTrue(mods[1].Enabled);
            }
示例#16
0
            public void Set_Assigned_Date_Already_Assigned()
            {
                string            assignedDate = null;
                IPlanElementUtils peUtil       = new PlanElementUtils {
                };
                DateTime assigned = DateTime.UtcNow;

                AD.Actions act = new AD.Actions {
                    AssignDate = assigned
                };
                AD.Program prog = new AD.Program {
                    AssignToId = assignedDate
                };

                peUtil.SetInitialProperties(assignedDate, act, false);

                Assert.AreEqual(assigned.Date, ((DateTime)act.AssignDate).Date);
            }
示例#17
0
            public void Set_AssignedTo_CM_Already_Assigned_In_Program()
            {
                string            assignedTO = ObjectId.GenerateNewId().ToString();
                IPlanElementUtils peUtil     = new PlanElementUtils {
                };
                DateTime assigned            = DateTime.UtcNow;

                AD.Actions act = new AD.Actions {
                    AssignDate = assigned
                };
                AD.Program prog = new AD.Program {
                    AssignToId = assignedTO
                };

                peUtil.SetInitialProperties(assignedTO, act, false);

                Assert.AreEqual(assignedTO, act.AssignToId);
            }
示例#18
0
            public void Set_Assigned_To_No_CM_Assigned_In_Program()
            {
                string            assignedTO = null;
                IPlanElementUtils peUtil     = new PlanElementUtils {
                };
                DateTime assigned            = DateTime.UtcNow;

                AD.Actions act = new AD.Actions {
                    AssignDate = assigned
                };
                AD.Program prog = new AD.Program {
                    AssignToId = assignedTO
                };

                peUtil.SetInitialProperties(assignedTO, act, false);

                Assert.IsNull(act.AssignToId);
            }
示例#19
0
            public void SetProgramAttributes_DoNot_Set_Program_State_state_1()
            {
                IPlanElementUtils pUtils = new PlanElementUtils {
                    ProgramAttributeStrategy = new ProgramAttributeStrategy()
                };
                var pe = new AD.PlanElement {
                    Enabled = false
                };
                var progAttr = new ProgramAttributeData();
                var prog     = new AD.Program {
                    Name = "test"
                };

                pUtils.SetProgramAttributes(new AD.SpawnElement {
                    Tag = "1", ElementType = 10, ElementId = "1234"
                }, prog, "user", progAttr);

                Assert.AreEqual(0, prog.ElementState);
            }
示例#20
0
 public void SetProgramAttributes_Null_attributes()
 {
     try
     {
         IPlanElementUtils pUtils = new PlanElementUtils();
         AD.PlanElement    pe     = new AD.PlanElement {
             Enabled = false
         };
         pUtils.SetProgramAttributes(new AD.SpawnElement {
             Tag = "0", ElementType = 19, ElementId = "1234"
         },
                                     new AD.Program {
             Name = "test"
         }, "user", null);
     }
     catch (Exception ex)
     {
         Assert.IsTrue(ex != null);
     }
 }
示例#21
0
            public void Set_One_Action_With_State_InProgress()
            {
                IPlanElementUtils pUtils = new PlanElementUtils();

                AD.Module mod = new AD.Module
                {
                    Enabled = true,
                    Actions = new List <AD.Actions>
                    {
                        new AD.Actions {
                            Enabled = true, ElementState = 4
                        },                                                 // inprogress
                        new AD.Actions {
                            Enabled = true, ElementState = 2
                        }                                                 // not started
                    }
                };

                pUtils.SetInitialActions(mod, "123456789012345678901234");

                Assert.IsNotNull(mod.Actions[1].AssignById);
            }
示例#22
0
            public void Set_One_Action_Assign_Date()
            {
                IPlanElementUtils pUtils = new PlanElementUtils();

                AD.Module mod = new AD.Module
                {
                    Enabled = true,
                    Actions = new List <AD.Actions>
                    {
                        new AD.Actions {
                            Enabled = true
                        },
                        new AD.Actions {
                            Enabled = false
                        }
                    }
                };

                pUtils.SetInitialActions(mod, "123456789012345678901234");

                Assert.AreEqual(DateTime.UtcNow.Date, ((DateTime)mod.Actions[0].AssignDate).Date);
            }
示例#23
0
            public void Set_One_Action()
            {
                IPlanElementUtils pUtils = new PlanElementUtils();

                AD.Module mod = new AD.Module
                {
                    Enabled = true,
                    Actions = new List <AD.Actions>
                    {
                        new AD.Actions {
                            Enabled = true
                        },
                        new AD.Actions {
                            Enabled = false
                        }
                    }
                };

                pUtils.SetInitialActions(mod, "123456789012345678901234");

                Assert.IsNotNull(mod.Actions[0].AssignById);
            }
示例#24
0
            public void Set_Element_State_Change_Date()
            {
                IPlanElementUtils peUtil = new PlanElementUtils {
                };

                AD.SpawnElement spwn = new AD.SpawnElement
                {
                    ElementId   = "123456789012345678901234",
                    ElementType = 12,
                    Tag         = "3"
                };
                AD.Program program = new AD.Program {
                    ElementState = 1
                };
                ProgramAttributeData progAttr = new ProgramAttributeData();

                peUtil.SetProgramAttributes(spwn, program, "UserId", progAttr);

                DateTime control = DateTime.UtcNow.Date;
                DateTime sample  = ((DateTime)program.StateUpdatedOn).Date;

                Assert.AreEqual(control, sample);
            }
示例#25
0
            public void Set_As_Enabled_Module_AssignDate()
            {
                IPlanElementUtils pUtils = new PlanElementUtils();

                var mods = new List <AD.Module>
                {
                    new AD.Module {
                        Id = "000006789012345678901234", Completed = true
                    },
                    new AD.Module
                    {
                        Enabled  = true,
                        Previous = "000006789012345678901234",
                        Actions  = new List <AD.Actions> {
                            new AD.Actions {
                                Enabled = true
                            }
                        }
                    }
                };

                pUtils.SetEnabledStatusByPrevious(mods, "123456789012345678901234", true);
                Assert.AreEqual(DateTime.UtcNow.Date, ((DateTime)mods[1].Actions[0].AssignDate).Date);
            }
示例#26
0
            public void Clone_Module_With_StateUpdateOn()
            {
                IPlanElementUtils peUtil = new PlanElementUtils();

                peUtil.CloneModule(new AD.Module());
            }
示例#27
0
            public void Update_Action_Assign_To()
            {
                IPlanElementUtils pUtils = new PlanElementUtils();

                var targetAction = ObjectId.GenerateNewId().ToString();

                AD.Program prog = new AD.Program
                {
                    Id      = ObjectId.GenerateNewId().ToString(),
                    Modules = new List <AD.Module>
                    {
                        new AD.Module
                        {
                            Id      = ObjectId.GenerateNewId().ToString(),
                            Actions = new List <AD.Actions>
                            {
                                new AD.Actions
                                {
                                    Id           = targetAction,
                                    ElementState = 2
                                },
                                new AD.Actions
                                {
                                    Id = ObjectId.GenerateNewId().ToString()
                                }
                            }
                        },
                        new AD.Module
                        {
                            Id      = ObjectId.GenerateNewId().ToString(),
                            Actions = new List <AD.Actions>
                            {
                                new AD.Actions
                                {
                                    Id = ObjectId.GenerateNewId().ToString()
                                },
                                new AD.Actions
                                {
                                    Id = ObjectId.GenerateNewId().ToString()
                                }
                            }
                        },
                    }
                };

                var assignToId = ObjectId.GenerateNewId().ToString();

                AD.PlanElement pe = new AD.PlanElement
                {
                    Id         = targetAction,
                    AssignToId = assignToId
                };

                var planElems = new DTO.PlanElements
                {
                    Actions  = new List <DTO.Actions>(),
                    Modules  = new List <DTO.Module>(),
                    Programs = new List <DTO.Program>(),
                    Steps    = new List <DTO.Step>()
                };

                pUtils.UpdatePlanElementAttributes(prog, pe, "111111111111111111111111", planElems);

                Assert.AreEqual(assignToId, prog.Modules[0].Actions[0].AssignToId);
            }