Ejemplo n.º 1
0
        private static List <ModelHelperInfo> GetModelParamPermutations(ModelHelperInfo mhi)
        {
            List <ModelHelperInfo> modelHelperInfos = new List <ModelHelperInfo>();

            modelHelperInfos.Add(mhi);

            // for each step in model
            List <DeploymentModelStepsStep> steps = mhi.modelHelper.AllSteps.ToList();

            for (int iStep = 0; iStep < steps.Count; iStep++)
            {
                // for each commandParam in step
                for (int iCommandParam = 0; iCommandParam < steps[iStep].CommandParam.Length; iCommandParam++)
                {
                    // get all variations of param values
                    List <ParamInfo> paramInfos = GetParamInfosForParameterName(steps[iStep].CommandParam[iCommandParam].ParameterName);

                    if ((paramInfos == null) || (paramInfos.Count == 0))
                    {
                        continue;
                    }

                    // make deep copies of existing models for each paramInfo in paramInfos
                    ModelHelperInfo.MakeDeepCopies(modelHelperInfos, paramInfos.Count, _currentDirName);

                    // add each param to that many models
                    int cModelsPerParam = modelHelperInfos.Count / paramInfos.Count;
                    for (int iParam = 0; iParam < paramInfos.Count; iParam++)
                    {
                        for (int iModel = iParam * cModelsPerParam; iModel < ((iParam + 1) * cModelsPerParam); iModel++)
                        {
                            modelHelperInfos[iModel].modelHelper.AddParameter(paramInfos[iParam].dmParam);

                            if (paramInfos[iParam].isNegativeTestCase)
                            {
                                modelHelperInfos[iModel].isNegativeTestCase = true;
                            }
                        }
                    }
                }
            }

            List <ParamInfo> unboundParams = _paramInfos.Where(e => e.isUnbound == true).ToList();

            if (unboundParams != null && unboundParams.Count() != 0)
            {
                foreach (ModelHelperInfo eachModelHelperInfo in modelHelperInfos)
                {
                    foreach (ParamInfo eachUnboundParam in unboundParams)
                    {
                        eachModelHelperInfo.modelHelper.AddParameter(eachUnboundParam.dmParam);
                    }
                }
            }
            return(modelHelperInfos);
        }
Ejemplo n.º 2
0
        private static List <ModelHelperInfo> GetModelsForStepSequence(string[] stepSequence)
        {
            List <ModelHelperInfo> modelHelperInfos = new List <ModelHelperInfo>();

            modelHelperInfos.Add(ModelHelperInfo.Create(_currentDirName)); // initialize with one model

            // add models for every variation of every step
            for (int iCommand = 0; iCommand < stepSequence.Length; iCommand++)
            {
                string commandString = stepSequence[iCommand];

                if (string.IsNullOrEmpty(commandString))
                {
                    continue;
                }

                IEnumerable <DeploymentModelStepsStep> steps = GetStepsForCommand(commandString);

                if ((steps == null) || (steps.Count() == 0))
                {
                    continue;
                }

                // make deep copies of existing models for each step in steps
                ModelHelperInfo.MakeDeepCopies(modelHelperInfos, steps.Count(), _currentDirName);

                // add each step to that many models
                int cModelsPerStep = modelHelperInfos.Count / steps.Count();
                for (int iStep = 0; iStep < steps.Count(); iStep++)
                {
                    for (int iModel = iStep * cModelsPerStep; iModel < ((iStep + 1) * cModelsPerStep); iModel++)
                    {
                        modelHelperInfos[iModel].modelHelper.AddStep(steps.ElementAt(iStep));
                    }
                }
            }

            // now add param values for every variation of param value for every commandParam
            List <ModelHelperInfo> modelHelperInfosNew = new List <ModelHelperInfo>();
            int cModels = modelHelperInfos.Count;

            for (int iModel = 0; iModel < cModels; iModel++)
            {
                modelHelperInfosNew.AddRange(GetModelParamPermutations(modelHelperInfos[iModel]));
            }

            return(modelHelperInfosNew);
        }