示例#1
0
 public RunSetTreeItem(RunSetConfig runSetConfig)
 {
     mRunSetConfig = runSetConfig;
 }
示例#2
0
        public void DynamicRunetExecutionTest()
        {
            //Arrange
            ObservableList <BusinessFlow> bfList = SR.GetAllRepositoryItems <BusinessFlow>();
            BusinessFlow BF1 = bfList[0];

            ObservableList <Activity> activityList = BF1.Activities;

            Activity activity = activityList[0];

            BF1.Active = true;

            GingerRunner mGRForRunset = new GingerRunner();

            mGRForRunset.Name = "Test Runner";

            Agent a = new Agent();

            a.DriverType = Agent.eDriverType.SeleniumChrome;

            mGRForRunset.SolutionAgents = new ObservableList <Agent>();
            mGRForRunset.SolutionAgents.Add(a);

            mGRForRunset.ApplicationAgents.Add(new ApplicationAgent()
            {
                AppName = "SCM", Agent = a
            });
            mGRForRunset.SolutionApplications = new ObservableList <ApplicationPlatform>();
            mGRForRunset.SolutionApplications.Add(new ApplicationPlatform()
            {
                AppName = "SCM", Platform = ePlatformType.Web, Description = "New application"
            });

            mGRForRunset.BusinessFlows.Add(BF1);
            WorkSpace.Instance.SolutionRepository = SR;

            mGRForRunset.SpecificEnvironmentName = environment.Name;
            mGRForRunset.UseSpecificEnvironment  = false;

            RunSetConfig runSetConfig1 = new RunSetConfig();

            mGRForRunset.IsUpdateBusinessFlowRunList = true;
            runSetConfig1.GingerRunners.Add(mGRForRunset);

            runSetConfig1.UpdateRunnersBusinessFlowRunsList();
            runSetConfig1.mRunModeParallel = false;

            RunSetActionHTMLReport produceHTML2 = CreateProduceHTMlOperation();

            runSetConfig1.RunSetActions.Add(produceHTML2);

            RunsetExecutor GMR1 = new RunsetExecutor();

            GMR1.RunsetExecutionEnvironment = environment;
            GMR1.RunSetConfig = runSetConfig1;
            WorkSpace.Instance.RunsetExecutor = GMR1;
            CLIHelper cLIHelper1 = new CLIHelper();

            cLIHelper1.RunAnalyzer       = false;
            cLIHelper1.ShowAutoRunWindow = false;
            cLIHelper1.DownloadUpgradeSolutionFromSourceControl = false;

            RunSetAutoRunConfiguration autoRunConfiguration1 = new RunSetAutoRunConfiguration(solution, GMR1, cLIHelper1);
            CLIDynamicFile             mCLIDynamicXML1       = new CLIDynamicFile(CLIDynamicFile.eFileType.XML);

            autoRunConfiguration1.SelectedCLI = mCLIDynamicXML1;
            String xmlFile = autoRunConfiguration1.SelectedCLI.CreateConfigurationsContent(solution, GMR1, cLIHelper1);

            autoRunConfiguration1.CreateContentFile();

            CLIProcessor cLIProcessor = new CLIProcessor();

            string[] args = new string[] { autoRunConfiguration1.SelectedCLI.Verb, "--" + CLIOptionClassHelper.FILENAME, autoRunConfiguration1.ConfigFileFullPath };

            //Act
            cLIProcessor.ExecuteArgs(args);

            //Assert
            string path = TestResources.GetTestResourcesFolder(@"Solutions" + Path.DirectorySeparatorChar + "BasicSimple" + Path.DirectorySeparatorChar + "Reports" + Path.DirectorySeparatorChar + "Reports");

            Assert.IsTrue(Directory.Exists(path));
        }
        public bool ProcessCommandLineArgs(string[] lines)
        {
            string scURL  = null;
            string scUser = null;
            string scPswd = null;

            foreach (string arg in lines)
            {
                int    i     = arg.IndexOf('=');
                string param = arg.Substring(0, i).Trim();
                string value = arg.Substring(i + 1).Trim();

                switch (param)
                {
                case "SourceControlType":
                    Reporter.ToLogAndConsole(eLogLevel.INFO, "Selected SourceControlType: '" + value + "'");
                    if (value.Equals("GIT"))
                    {
                        App.UserProfile.SourceControlType = SourceControlBase.eSourceControlType.GIT;
                    }
                    else if (value.Equals("SVN"))
                    {
                        App.UserProfile.SourceControlType = SourceControlBase.eSourceControlType.SVN;
                    }
                    else
                    {
                        App.UserProfile.SourceControlType = SourceControlBase.eSourceControlType.None;
                    }
                    break;

                case "SourceControlUrl":
                    Reporter.ToLogAndConsole(eLogLevel.INFO, "Selected SourceControlUrl: '" + value + "'");
                    if (App.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.SVN)
                    {
                        if (!value.ToUpper().Contains("/SVN") && !value.ToUpper().Contains("/SVN/"))
                        {
                            value = value + "svn/";
                        }
                        if (!value.ToUpper().EndsWith("/"))
                        {
                            value = value + "/";
                        }
                    }
                    App.UserProfile.SourceControlURL = value;
                    scURL = value;
                    break;

                case "SourceControlUser":
                    Reporter.ToLogAndConsole(eLogLevel.INFO, "Selected SourceControlUser: '******'");
                    if (App.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.GIT && value == "")
                    {
                        value = "Test";
                    }
                    App.UserProfile.SourceControlUser = value;
                    scUser = value;
                    break;

                case "SourceControlPassword":
                    Reporter.ToLogAndConsole(eLogLevel.INFO, "Selected SourceControlPassword: '******'");
                    App.UserProfile.SourceControlPass = value;
                    scPswd = value;
                    break;

                case "PasswordEncrypted":
                    Reporter.ToLogAndConsole(eLogLevel.INFO, "PasswordEncrypted: '" + value + "'");
                    string pswd = App.UserProfile.SourceControlPass;
                    if (value == "Y")
                    {
                        pswd = EncryptionHandler.DecryptwithKey(App.UserProfile.SourceControlPass, App.ENCRYPTION_KEY);
                    }
                    if (App.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.GIT && pswd == "")
                    {
                        pswd = "Test";
                    }
                    App.UserProfile.SourceControlPass = pswd;
                    break;

                case "SourceControlProxyServer":
                    Reporter.ToLogAndConsole(eLogLevel.INFO, "Selected SourceControlProxyServer: '" + value + "'");
                    if (value == "")
                    {
                        App.UserProfile.SolutionSourceControlConfigureProxy = false;
                    }
                    else
                    {
                        App.UserProfile.SolutionSourceControlConfigureProxy = true;
                    }
                    if (value != "" && !value.ToUpper().StartsWith("HTTP://"))
                    {
                        value = "http://" + value;
                    }
                    App.UserProfile.SolutionSourceControlProxyAddress = value;
                    break;

                case "SourceControlProxyPort":
                    if (value == "")
                    {
                        App.UserProfile.SolutionSourceControlConfigureProxy = false;
                    }
                    else
                    {
                        App.UserProfile.SolutionSourceControlConfigureProxy = true;
                    }
                    Reporter.ToLogAndConsole(eLogLevel.INFO, "Selected SourceControlProxyPort: '" + value + "'");
                    App.UserProfile.SolutionSourceControlProxyPort = value;
                    break;

                case "Solution":
                    if (scURL != null && scUser != "" && scPswd != null)
                    {
                        Reporter.ToLogAndConsole(eLogLevel.INFO, "Downloading Solution from source control");
                        if (value.IndexOf(".git") != -1)
                        {
                            App.DownloadSolution(value.Substring(0, value.IndexOf(".git") + 4));
                        }
                        else
                        {
                            App.DownloadSolution(value);
                        }
                    }
                    Reporter.ToLog(eLogLevel.INFO, "Loading the Solution: '" + value + "'");
                    try
                    {
                        if (App.SetSolution(value) == false)
                        {
                            Reporter.ToLog(eLogLevel.ERROR, "Failed to load the Solution");
                            return(false);
                        }
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Failed to load the Solution");
                        Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex);
                        return(false);
                    }
                    break;

                case "Env":
                    Reporter.ToLog(eLogLevel.INFO, "Selected Environment: '" + value + "'");
                    ProjEnvironment env = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ProjEnvironment>().Where(x => x.Name.ToLower().Trim() == value.ToLower().Trim()).FirstOrDefault();
                    if (env != null)
                    {
                        App.RunsetExecutor.RunsetExecutionEnvironment = env;
                    }
                    else
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Failed to find matching Environment in the Solution");
                        return(false);
                    }
                    break;

                case "RunSet":
                    Reporter.ToLog(eLogLevel.INFO, string.Format("Selected {0}: '{1}'", GingerDicser.GetTermResValue(eTermResKey.RunSet), value));
                    ObservableList <RunSetConfig> RunSets = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <RunSetConfig>();
                    RunSetConfig runSetConfig             = RunSets.Where(x => x.Name.ToLower().Trim() == value.ToLower().Trim()).FirstOrDefault();
                    if (runSetConfig != null)
                    {
                        WorkSpace.RunsetExecutor.RunSetConfig = runSetConfig;
                    }
                    else
                    {
                        Reporter.ToLog(eLogLevel.ERROR, string.Format("Failed to find matching {0} in the Solution", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                        return(false);
                    }
                    break;

                default:
                    Reporter.ToLog(eLogLevel.ERROR, "Un Known argument: '" + param + "'");
                    return(false);
                }
            }
            return(true);
        }
        public static List<AnalyzerItemBase> Analyze(RunSetConfig RSC)
        {
            List<AnalyzerItemBase> IssuesList = new List<AnalyzerItemBase>();
            // check that we have Runners
            if (RSC.GingerRunners.Count() == 0)
            {
                RunSetConfigAnalyzer AGR = CreateNewIssue(IssuesList, RSC);
                AGR.Description = "Missing Runners";
                AGR.Details = "No Runners to run";
                AGR.HowToFix = "Add Runners";
                AGR.CanAutoFix = AnalyzerItemBase.eCanFix.No;
                AGR.IssueType = eType.Warning;
                AGR.Impact = "Nothing to run";
                AGR.Severity = eSeverity.Medium;
                AGR.Selected = false;
            }

            //check we do not have duplicates Agents
            if (RSC.RunModeParallel)
            {
                List<Guid> Agents = new List<Guid>();
                foreach (GingerRunner GR in RSC.GingerRunners)
                {
                    foreach (ApplicationAgent AA in GR.ApplicationAgents)
                    {
                        if (AA.Agent != null)
                        {
                            if (AA.Agent.AgentOperations == null)
                            {
                                AA.Agent.AgentOperations = new AgentOperations(AA.Agent);
                            }
                        }
                        if (AA.Agent == null) continue;//no Agent so skip it

                        Guid agnetGuide = (from x in Agents where x == AA.Agent.Guid select x).FirstOrDefault();
                        if (agnetGuide == Guid.Empty)
                            Agents.Add(AA.Agent.Guid);
                        else
                        {
                            if (!AA.Agent.SupportVirtualAgent())
                            {
                                //create error
                                RunSetConfigAnalyzer AGR = CreateNewIssue(IssuesList, RSC);
                                AGR.ItemParent = GR.Name;
                                AGR.Description = "Same Agent was configured on more than one Runner";
                                AGR.Details = string.Format("The '{0}' Runner '{1}' Target Application is mapped to the '{2}' Agent which is already configured on another Runner", GR.Name, AA.AppName, AA.AgentName);
                                AGR.HowToFix = "Map the Target Application to different Agent";
                                AGR.CanAutoFix = AnalyzerItemBase.eCanFix.No;
                                AGR.IssueType = eType.Error;
                                AGR.Impact = "Execution will fail.";
                                AGR.Severity = eSeverity.Critical;
                                AGR.Selected = false;
                            }
                        }
                    }
                }
            }

            //check all configured mapped data still valid
            foreach (GingerRunner GR in RSC.GingerRunners)
            {
                foreach (BusinessFlow bf in GR.Executor.BusinessFlows)
                {
                    List<VariableBase> inputVars = bf.GetBFandActivitiesVariabeles(true).ToList();
                    List<VariableBase> optionalVariables = null;
                    List<VariableBase> optionalOutputVariables = null;
                    foreach (VariableBase inputVar in inputVars)
                    {
                        bool issueExist = false;
                        Guid mappedGuid = Guid.Empty;
                        switch (inputVar.MappedOutputType)
                        {
                            case VariableBase.eOutputType.Variable:
                                if (optionalVariables == null)
                                {
                                    optionalVariables = ((GingerExecutionEngine)GR.Executor).GetPossibleOutputVariables(RSC, bf, includeGlobalVars: true, includePrevRunnersVars: false);
                                }
                                issueExist = optionalVariables.Where(x => x.Name == inputVar.MappedOutputValue).FirstOrDefault() == null;
                                break;
                            case VariableBase.eOutputType.OutputVariable:
                                if (optionalOutputVariables == null)
                                {
                                    optionalOutputVariables = ((GingerExecutionEngine)GR.Executor).GetPossibleOutputVariables(RSC, bf, includeGlobalVars: false, includePrevRunnersVars: true);
                                }                              
                                issueExist = optionalOutputVariables.Where(x => x.VariableInstanceInfo == inputVar.MappedOutputValue).FirstOrDefault() == null;
                                break;
                            case VariableBase.eOutputType.GlobalVariable:                                
                                Guid.TryParse(inputVar.MappedOutputValue, out mappedGuid);
                                issueExist = WorkSpace.Instance.Solution.Variables.Where(x => x.Guid == mappedGuid).FirstOrDefault() == null;
                                break;
                            case VariableBase.eOutputType.ApplicationModelParameter:
                                Guid.TryParse(inputVar.MappedOutputValue, out mappedGuid);
                                issueExist = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<GlobalAppModelParameter>().Where(x => x.Guid == mappedGuid).FirstOrDefault() == null;
                                break;
                            case VariableBase.eOutputType.DataSource:
                                issueExist = string.IsNullOrEmpty(inputVar.MappedOutputValue);
                                break;
                        }

                        if (issueExist)
                        {
                            //create error
                            RunSetConfigAnalyzer AGR = CreateNewIssue(IssuesList, RSC);
                            AGR.ItemParent = GR.Name;
                            AGR.Description = string.Format("Configured input {0} data mapping from type '{1}' is missing", GingerDicser.GetTermResValue(eTermResKey.Variable), inputVar.MappedOutputType);
                            AGR.Details = string.Format("In '{0}' Runner, '{1}' {2}, the configured input {3} '{4}' data mapping from type '{5}' and value '{6}' is missing", GR.Name, bf.Name, GingerDicser.GetTermResValue(eTermResKey.BusinessFlow), GingerDicser.GetTermResValue(eTermResKey.Variable), inputVar.Name, inputVar.MappedOutputType, inputVar.MappedOutputValue);
                            AGR.HowToFix = string.Format("Re-configure the missing input {0} data mapping", GingerDicser.GetTermResValue(eTermResKey.Variable));
                            AGR.CanAutoFix = AnalyzerItemBase.eCanFix.No;
                            AGR.IssueType = eType.Error;
                            AGR.Impact = "Execution might fail due to wrong data mapping";
                            AGR.Severity = eSeverity.High;
                            AGR.Selected = false;
                        }
                    }
                }
            }

            return IssuesList;
        }        
 static RunSetConfigAnalyzer CreateNewIssue(List<AnalyzerItemBase> IssuesList, RunSetConfig RSC)
 {
     RunSetConfigAnalyzer RSCA = new RunSetConfigAnalyzer();
     RSCA.Status = AnalyzerItemBase.eStatus.NeedFix;            
     RSCA.ItemName = RSC.Name;
     RSCA.ItemClass = "Run Set";
     IssuesList.Add(RSCA);
     return RSCA;
 }
        public static void CreateRealRunSetFromDynamic(RunsetExecutor runsetExecutor, AddRunset dynamicRunset)
        {
            RunSetConfig runSetConfig = new RunSetConfig();

            runSetConfig.Name            = dynamicRunset.Name;
            runSetConfig.RunWithAnalyzer = dynamicRunset.RunAnalyzer;
            runSetConfig.RunModeParallel = dynamicRunset.RunInParallel;

            // Add runners
            foreach (AddRunner addRunner in dynamicRunset.AddRunners)
            {
                GingerRunner gingerRunner = new GingerRunner();
                gingerRunner.Name = addRunner.Name;

                if (!string.IsNullOrEmpty(addRunner.RunMode))
                {
                    gingerRunner.RunOption = (GingerRunner.eRunOptions)Enum.Parse(typeof(GingerRunner.eRunOptions), addRunner.RunMode, true);
                }

                if (!string.IsNullOrEmpty(addRunner.Environment))
                {
                    gingerRunner.UseSpecificEnvironment  = true;
                    gingerRunner.SpecificEnvironmentName = addRunner.Environment;
                }

                //add Agents
                foreach (SetAgent setAgent in addRunner.SetAgents)
                {
                    ApplicationAgent appAgent = new ApplicationAgent();
                    appAgent.AppName   = setAgent.ApplicationName;
                    appAgent.AgentName = setAgent.AgentName;
                    gingerRunner.ApplicationAgents.Add(appAgent);
                }

                // Add BFs
                foreach (AddBusinessFlow addBusinessFlow in addRunner.AddBusinessFlows)
                {
                    BusinessFlowRun businessFlowRun = new BusinessFlowRun();
                    businessFlowRun.BusinessFlowName     = addBusinessFlow.Name;
                    businessFlowRun.BusinessFlowIsActive = true;

                    // set BF Variables
                    if (addBusinessFlow.InputVariables != null)
                    {
                        foreach (InputVariable inputVariabel in addBusinessFlow.InputVariables)
                        {
                            businessFlowRun.BusinessFlowCustomizedRunVariables.Add(new VariableString()
                            {
                                DiffrentFromOrigin = true, VarValChanged = true, ParentType = inputVariabel.VariableParentType, ParentName = inputVariabel.VariableParentName, Name = inputVariabel.VariableName, InitialStringValue = inputVariabel.VariableValue, Value = inputVariabel.VariableValue
                            });
                        }
                    }
                    gingerRunner.BusinessFlowsRunList.Add(businessFlowRun);
                }
                runSetConfig.GingerRunners.Add(gingerRunner);
            }

            //Add mail Report handling
            foreach (AddRunsetOperation addOperation in dynamicRunset.AddRunsetOperations)
            {
                if (addOperation is MailReport)
                {
                    MailReport dynamicMailOperation = (MailReport)addOperation;
                    RunSetActionHTMLReportSendEmail mailOperation = new RunSetActionHTMLReportSendEmail();

                    mailOperation.Name      = "Dynamic Mail Report";
                    mailOperation.Condition = (RunSetActionBase.eRunSetActionCondition)Enum.Parse(typeof(RunSetActionBase.eRunSetActionCondition), dynamicMailOperation.Condition, true);
                    mailOperation.RunAt     = (RunSetActionBase.eRunAt)Enum.Parse(typeof(RunSetActionBase.eRunAt), dynamicMailOperation.RunAt, true);
                    mailOperation.Active    = true;

                    mailOperation.MailFrom = dynamicMailOperation.MailFrom;
                    mailOperation.MailTo   = dynamicMailOperation.MailTo;
                    mailOperation.MailCC   = dynamicMailOperation.MailCC;

                    mailOperation.Subject  = dynamicMailOperation.Subject;
                    mailOperation.Comments = dynamicMailOperation.Comments;
                    //mailOperation.Comments = string.Format("Dynamic {0} Execution Report" + GingerDicser.GetTermResValue(eTermResKey.RunSet));

                    mailOperation.HTMLReportTemplate           = RunSetActionHTMLReportSendEmail.eHTMLReportTemplate.HTMLReport;
                    mailOperation.selectedHTMLReportTemplateID = 100;//ID to mark defualt template

                    mailOperation.Email.IsBodyHTML  = true;
                    mailOperation.Email.EmailMethod = GingerCore.GeneralLib.Email.eEmailMethod.SMTP;
                    mailOperation.Email.MailFrom    = dynamicMailOperation.MailFrom;
                    mailOperation.Email.MailTo      = dynamicMailOperation.MailTo;
                    mailOperation.Email.Subject     = dynamicMailOperation.Subject;
                    if (dynamicMailOperation.SendViaOutlook)
                    {
                        mailOperation.Email.EmailMethod = GingerCore.GeneralLib.Email.eEmailMethod.OUTLOOK;
                    }
                    else
                    {
                        if (dynamicMailOperation.SmtpDetails != null)
                        {
                            mailOperation.Email.EmailMethod  = GingerCore.GeneralLib.Email.eEmailMethod.SMTP;
                            mailOperation.Email.SMTPMailHost = dynamicMailOperation.SmtpDetails.Server;
                            mailOperation.Email.SMTPPort     = int.Parse(dynamicMailOperation.SmtpDetails.Port);
                            mailOperation.Email.EnableSSL    = bool.Parse(dynamicMailOperation.SmtpDetails.EnableSSL);
                            if (string.IsNullOrEmpty(dynamicMailOperation.SmtpDetails.User) == false)
                            {
                                mailOperation.Email.ConfigureCredential = true;
                                mailOperation.Email.SMTPUser            = dynamicMailOperation.SmtpDetails.User;
                                mailOperation.Email.SMTPPass            = dynamicMailOperation.SmtpDetails.Password;
                            }
                        }
                    }

                    if (dynamicMailOperation.IncludeAttachmentReport)
                    {
                        EmailHtmlReportAttachment reportAttachment = new EmailHtmlReportAttachment();
                        reportAttachment.AttachmentType = EmailAttachment.eAttachmentType.Report;
                        reportAttachment.ZipIt          = true;
                        mailOperation.EmailAttachments.Add(reportAttachment);
                    }

                    runSetConfig.RunSetActions.Add(mailOperation);
                }
                else if (addOperation is JsonReport)
                {
                    JsonReport dynamicJsonReport = (JsonReport)addOperation;
                    RunSetActionJSONSummary jsonReportOperation = new RunSetActionJSONSummary();

                    jsonReportOperation.Name      = "Dynamic Json Report";
                    jsonReportOperation.Condition = (RunSetActionBase.eRunSetActionCondition)Enum.Parse(typeof(RunSetActionBase.eRunSetActionCondition), dynamicJsonReport.Condition, true);
                    jsonReportOperation.RunAt     = (RunSetActionBase.eRunAt)Enum.Parse(typeof(RunSetActionBase.eRunAt), dynamicJsonReport.RunAt, true);
                    jsonReportOperation.Active    = true;

                    runSetConfig.RunSetActions.Add(jsonReportOperation);
                }
                else if (addOperation is ProduceHTML)
                {
                    ProduceHTML            dynamicReport   = (ProduceHTML)addOperation;
                    RunSetActionHTMLReport reportOpertaion = new RunSetActionHTMLReport();

                    reportOpertaion.Name      = "Dynamic HTML Report";
                    reportOpertaion.Condition = (RunSetActionBase.eRunSetActionCondition)Enum.Parse(typeof(RunSetActionBase.eRunSetActionCondition), dynamicReport.Condition, true);
                    reportOpertaion.RunAt     = (RunSetActionBase.eRunAt)Enum.Parse(typeof(RunSetActionBase.eRunAt), dynamicReport.RunAt, true);
                    reportOpertaion.Active    = true;
                    reportOpertaion.selectedHTMLReportTemplateID = dynamicReport.selectedHTMLReportTemplateID;
                    reportOpertaion.isHTMLReportFolderNameUsed   = dynamicReport.isHTMLReportFolderNameUsed;
                    if (dynamicReport.isHTMLReportFolderNameUsed)
                    {
                        reportOpertaion.HTMLReportFolderName = dynamicReport.HTMLReportFolderName;
                    }
                    reportOpertaion.isHTMLReportPermanentFolderNameUsed = dynamicReport.isHTMLReportPermanentFolderNameUsed;


                    runSetConfig.RunSetActions.Add(reportOpertaion);
                }
            }

            // Set config
            runsetExecutor.RunSetConfig = runSetConfig;
        }
示例#7
0
        public void TestInitialize()
        {
            WorkSpace.Init(new WorkSpaceEventHandler());
            WorkSpace.Instance.SolutionRepository = GingerSolutionRepository.CreateGingerSolutionRepository();

            // Init SR
            mSolutionRepository = WorkSpace.Instance.SolutionRepository;
            string TempRepositoryFolder = TestResources.GetTestTempFolder(Path.Combine("Solutions", "temp"));

            mSolutionRepository.Open(TempRepositoryFolder);
            Ginger.SolutionGeneral.Solution sol = new Ginger.SolutionGeneral.Solution();
            sol.ContainingFolderFullPath = TempRepositoryFolder;
            WorkSpace.Instance.Solution  = sol;
            mSolutionRepository.StopAllRepositoryFolderWatchers();

            WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder = Path.Combine(TempRepositoryFolder, "ExecutionResults");

            runset      = new RunSetConfig();
            runset.Name = "NewRunset1";
            WorkSpace.Instance.RunsetExecutor.RunSetConfig = runset;
            runner                 = new GingerRunner();
            runner.Name            = "Runner1";
            runner.CurrentSolution = new Ginger.SolutionGeneral.Solution();
            WorkSpace.Instance.RunsetExecutor.Runners.Add(runner);
            mEnv      = new ProjEnvironment();
            mEnv.Name = "Environment1";
            EnvApplication app1 = new EnvApplication();

            app1.Name = "App1";
            app1.Url  = "URL123";
            mEnv.Applications.Add(app1);
            GeneralParam GP1 = new GeneralParam();

            GP1.Name  = "GP1";
            GP1.Value = "GP1Value";
            app1.GeneralParams.Add(GP1);

            mBF      = new BusinessFlow();
            mBF.Name = "Businessflow1";
            runner.BusinessFlows.Add(mBF);
            mActivity              = new GingerCore.Activity();
            mActivity.Active       = true;
            mActivity.ActivityName = "Activity1";
            mAct             = new ActDummy();
            mAct.Active      = true;
            mAct.Description = "Action1";
            mActivity.Acts.Add(mAct);
            mActivity.Acts.CurrentItem = mAct;
            mBF.AddActivity(mActivity);


            BusinessFlow BF1 = new BusinessFlow();

            BF1.Name = "Businessflow2";
            runner.BusinessFlows.Add(BF1);
            GingerCore.Activity activity = new GingerCore.Activity();
            activity.Active       = true;
            activity.ActivityName = "Activity1";
            ActDummy dummy = new ActDummy();

            dummy.Active      = true;
            dummy.Description = "Dummy1";
            activity.Acts.Add(dummy);
            activity.Acts.CurrentItem = dummy;
            BF1.AddActivity(activity);
        }
示例#8
0
        private static void SetRunSetChildCounts(RunSetConfig runSet, AccountReportRunSet accountReportRunSet)
        {
            int    ChildExecutableItemsCountActivity = 0;
            int    ChildExecutedItemsCountActivity   = 0;
            int    ChildPassedItemsCountActivity     = 0;
            int    ChildExecutableItemsCountAction   = 0;
            int    ChildExecutedItemsCountAction     = 0;
            int    ChildPassedItemsCountAction       = 0;
            string Actvities = HTMLReportConfiguration.eExecutionStatisticsCountBy.Activities.ToString();
            string Actions   = HTMLReportConfiguration.eExecutionStatisticsCountBy.Actions.ToString();

            foreach (GingerRunner runner in runSet.GingerRunners)
            {
                int count = 0;
                foreach (BusinessFlow businessFlow in runner.Executor.BusinessFlows)
                {
                    ChildExecutableItemsCountActivity = ChildExecutableItemsCountActivity + businessFlow.Activities.Count(x => x.Active == true);

                    ChildExecutedItemsCountActivity = ChildExecutedItemsCountActivity + businessFlow.Activities.Where(ac => ac.Status == eRunStatus.Failed || ac.Status == eRunStatus.Passed || ac.Status == eRunStatus.FailIgnored || ac.Status == eRunStatus.Stopped || ac.Status == eRunStatus.Completed).Count();

                    ChildPassedItemsCountActivity = ChildPassedItemsCountActivity + businessFlow.Activities.Where(ac => ac.Status == eRunStatus.Passed).Count();

                    foreach (Activity activity in businessFlow.Activities)
                    {
                        ChildExecutableItemsCountAction = ChildExecutableItemsCountAction + activity.Acts.Count(x => x.Active == true);

                        ChildExecutedItemsCountAction = ChildExecutedItemsCountAction + activity.Acts.Count(x => x.Status == eRunStatus.Passed || x.Status == eRunStatus.Failed || x.Status == eRunStatus.FailIgnored || x.Status == eRunStatus.Stopped || x.Status == eRunStatus.Completed);

                        ChildPassedItemsCountAction = ChildPassedItemsCountAction + activity.Acts.Count(x => x.Status == eRunStatus.Passed);
                    }
                }
            }
            accountReportRunSet.ChildExecutableItemsCount = new List <AccountReport.Contracts.Helpers.DictObject>();
            accountReportRunSet.ChildExecutableItemsCount.Add(new AccountReport.Contracts.Helpers.DictObject
            {
                Key = Actvities, Value = ChildExecutableItemsCountActivity
            });

            accountReportRunSet.ChildExecutedItemsCount = new List <AccountReport.Contracts.Helpers.DictObject>();
            accountReportRunSet.ChildExecutedItemsCount.Add(new AccountReport.Contracts.Helpers.DictObject
            {
                Key = Actvities, Value = ChildExecutedItemsCountActivity
            });

            accountReportRunSet.ChildPassedItemsCount = new List <AccountReport.Contracts.Helpers.DictObject>();
            accountReportRunSet.ChildPassedItemsCount.Add(new AccountReport.Contracts.Helpers.DictObject
            {
                Key = Actvities, Value = ChildPassedItemsCountActivity
            });

            accountReportRunSet.ChildExecutableItemsCount.Add(new AccountReport.Contracts.Helpers.DictObject
            {
                Key = Actions, Value = ChildExecutableItemsCountAction
            });

            accountReportRunSet.ChildExecutedItemsCount.Add(new AccountReport.Contracts.Helpers.DictObject
            {
                Key = Actions, Value = ChildExecutedItemsCountAction
            });

            accountReportRunSet.ChildPassedItemsCount.Add(new AccountReport.Contracts.Helpers.DictObject
            {
                Key = Actions, Value = ChildPassedItemsCountAction
            });
        }