예제 #1
0
 private static void OnLeave(ExecutionStep guard, Action action)
 {
     if (guard == ExecutionStep.LeaveState)
     {
         action();
     }
 }
            // Executed before and after every state transition :
            private void StateChange(IState <Television> state, ExecutionStep step, Television value, TvOperation info, DateTime args)
            {
                // Holds during all possible transitions defined in the state graph :
                System.Diagnostics.Debug.Assert((step != ExecutionStep.LeaveState) || !state.IsFinal);

                // Holds in instance (i.e., non-static) transition handlers like this one :
                System.Diagnostics.Debug.Assert(this == state);

                switch (step)
                {
                case ExecutionStep.LeaveState:
                    var timeStamp = ((args != default(DateTime)) ? String.Format("\t\t(@ {0})", args) : String.Empty);
                    Console.WriteLine();
                    // 'value' is the state value that we are transitioning TO :
                    Console.WriteLine("\tLeave :\t{0} -- {1} -> {2}{3}", this, info, value, timeStamp);
                    break;

                case ExecutionStep.EnterState:
                    // 'value' is the state value that we have transitioned FROM :
                    Console.WriteLine("\tEnter :\t{0} -- {1} -> {2}", value, info, this);
                    break;

                default:
                    break;
                }
            }
예제 #3
0
 private static void AssertStep(ExecutionStep step, string stepTitle, ExecutionOrder order, bool asserts = false, bool shouldReport = true)
 {
     Assert.That(step.StepTitle.Trim(), Is.EqualTo(stepTitle));
     Assert.That(step.Asserts, Is.EqualTo(asserts));
     Assert.That(step.ExecutionOrder, Is.EqualTo(order));
     Assert.That(step.ShouldReport, Is.EqualTo(shouldReport));
 }
예제 #4
0
 private static void OnEnter(ExecutionStep guard, Action action)
 {
     if (guard == ExecutionStep.EnterState)
     {
         action();
     }
 }
예제 #5
0
 // Executed before and after every state transition :
 protected override void OnChange(ExecutionStep step, Status value, string info, object args)
 {
     OnEnter(step, () => {
         // 'value' is the state value that we have transitioned FROM :
         Console.WriteLine("\t{0} -- {1} -> {2}", value, info, this);
     });
 }
예제 #6
0
 // Executed before and after every state transition :
 protected override void OnChange(ExecutionStep step, Status value, string info, DateTime args)
 {
     OnEnter(step, () => {
         var timeStamp = String.Format("\t\t(@ {0})", (args != default(DateTime)) ? args : DateTime.Now);
         // 'value' is the state value that we have transitioned FROM :
         Console.WriteLine("\t{0} -- {1} -> {2}{3}", value, info, this, timeStamp);
     });
 }
        public static ExecutionStep Load(int executionStepId)
        {
            // load your execution and step data here and return it
            // within ExecutionStep class object
            ExecutionStep executionStep = new ExecutionStep();

            executionStep.Execution = db.Executions.Find(id);
            executionStep.Steps     = db..... // load steps from db
                                      return(executionStep);
        }
예제 #8
0
 public void Show(string msg)
 {
     Console.WriteLine("Application.Show is waiting for input:");
     Console.ReadLine();
     System.Diagnostics.Debugger.Break();
     string name = "system.web";
     Console.WriteLine(name);
     Application.IExecuteStep obj = new ExecutionStep();
     obj.Execute();
     Console.WriteLine(msg);
 }
예제 #9
0
        public void Show(string msg)
        {
            Console.WriteLine("Application.Show is waiting for input:");
            Console.ReadLine();
            System.Diagnostics.Debugger.Break();
            string name = "system.web";

            Console.WriteLine(name);
            Application.IExecuteStep obj = new ExecutionStep();
            obj.Execute();
            Console.WriteLine(msg);
        }
예제 #10
0
        static string PrefixWithSpaceIfRequired(ExecutionStep step)
        {
            var stepTitle      = step.StepTitle;
            var executionOrder = step.ExecutionOrder;

            if (executionOrder == ExecutionOrder.ConsecutiveAssertion ||
                executionOrder == ExecutionOrder.ConsecutiveSetupState ||
                executionOrder == ExecutionOrder.ConsecutiveTransition)
            {
                stepTitle = "  " + stepTitle; // add two spaces in the front for indentation.
            }
            return(stepTitle.Replace(Environment.NewLine, Environment.NewLine + "\t\t"));
        }
예제 #11
0
        void ReportOnStep(Scenario scenario, ExecutionStep step)
        {
            var message =
                string.Format
                    ("\t{0}  [{1}] ",
                    PrefixWithSpaceIfRequired(step).PadRight(_longestStepSentence + 5),
                    Configurator.Scanners.Humanize(step.Result.ToString()));

            // if all the steps have passed, there is no reason to make noise
            if (scenario.Result == StepExecutionResult.Passed)
            {
                message = "\t" + PrefixWithSpaceIfRequired(step);
            }

            if (step.Exception != null)
            {
                _exceptions.Add(step.Exception);

                var exceptionReference = string.Format("[Details at {0} below]", _exceptions.Count);
                if (!string.IsNullOrEmpty(step.Exception.Message))
                {
                    message += string.Format("[{0}] {1}", FlattenExceptionMessage(step.Exception.Message), exceptionReference);
                }
                else
                {
                    message += string.Format("{0}", exceptionReference);
                }
            }

            if (step.Result == StepExecutionResult.Inconclusive || step.Result == StepExecutionResult.NotImplemented)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
            }
            else if (step.Result == StepExecutionResult.Failed)
            {
                Console.ForegroundColor = ConsoleColor.Red;
            }
            else if (step.Result == StepExecutionResult.NotExecuted)
            {
                Console.ForegroundColor = ConsoleColor.Gray;
            }

            Console.WriteLine(message);
            Console.ForegroundColor = ConsoleColor.White;
        }
예제 #12
0
    protected ExecutionStep(IReadOnlyList <ExecutionStep>?steps = null)
    {
        if (steps is not null)
        {
            Debug.Assert(steps.Count > 0, "Steps cannot be empty.");

            ExecutionStep?previous = null;

            for (var index = 0; index < steps.Count; index++)
            {
                ExecutionStep step = steps[index];
                step.Parent = this;

                if (previous is not null)
                {
                    previous.Next = step;
                }

                previous = step;
            }
        }

        Steps = steps ?? Array.Empty <ExecutionStep>();
    }
예제 #13
0
 protected override void OnChange(ExecutionStep step, ProcessState value, Command trigger, object args)
 {
     OnEnter(step, () => {
         Console.WriteLine("In OnChange(...) : {0} --{1}-> {2}", value, trigger, this.Value);
     });
 }
예제 #14
0
        public static CompilationUnit ParseCobolFile(string textName, DocumentFormat documentFormat = null, string folder = null, ExecutionStep execToStep = ExecutionStep.SemanticCheck)
        {
            if (folder == null)
            {
                folder = "Parser" + Path.DirectorySeparatorChar + "CodeElements";
            }
            DirectoryInfo localDirectory = new DirectoryInfo(PlatformUtils.GetPathForProjectFile(folder));

            if (!localDirectory.Exists)
            {
                throw new Exception(String.Format("Directory : {0} does not exist", localDirectory.FullName));
            }
            if (documentFormat == null)
            {
                documentFormat = DocumentFormat.RDZReferenceFormat;
            }

            TypeCobolOptions options = new TypeCobolOptions {
                ExecToStep = execToStep
            };                                                  //Create CompilerOptions. ExecToStep / AutoRemarks / HaltOnMissingCopy have to be set here.
            CompilationProject project = new CompilationProject("test",
                                                                //First use *.cpy as tests will use file WITH extension for program but without extension for copy inside programs => small perf gain
                                                                localDirectory.FullName, new string[] { ".cpy", ".cbl" },
                                                                documentFormat.Encoding, documentFormat.EndOfLineDelimiter, documentFormat.FixedLineLength, documentFormat.ColumnsLayout, options);
            FileCompiler compiler = new FileCompiler(null, textName, project.SourceFileProvider, project, documentFormat.ColumnsLayout, options, null, false, project);

            compiler.CompileOnce();

            return(compiler.CompilationResultsForProgram);
        }
예제 #15
0
        private ExecutionResult GetExeResultforAg(BusinessFlow businessFlow, string bfExportedID, ActivitiesGroup activGroup, ref string result, RQMTestPlan testPlan)
        {
            try
            {
                LoginDTO loginData = new LoginDTO()
                {
                    User = ALMCore.AlmConfig.ALMUserName, Password = ALMCore.AlmConfig.ALMPassword, Server = ALMCore.AlmConfig.ALMServerURL
                };

                if (string.IsNullOrEmpty(activGroup.ExternalID))
                {
                    result = "At " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + ": " + businessFlow.Name + " " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroup) + ", is missing ExternalID, cannot export RQM TestPlan execution results without External ID";
                    return(null);
                }

                ExecutionResult exeResult = new ExecutionResult {
                    TestPlanExportID = bfExportedID
                };

                List <Activity> relevantActivities = new List <Activity>();
                relevantActivities      = businessFlow.Activities.Where(x => x.ActivitiesGroupID == activGroup.FileName).ToList();
                exeResult.ExecutionStep = new List <ExecutionStep>();

                string txExportID = GetExportedIDString(activGroup.ExternalID, "RQMID");
                string tsExportID = GetExportedIDString(activGroup.ExternalID, "RQMScriptID");
                string erExportID = GetExportedIDString(activGroup.ExternalID, "RQMRecordID");
                if ((activGroup.TestSuiteId != null) && (activGroup.TestSuiteId != string.Empty))
                {
                    // check if test suite execution record is exists per current Test Suite ID
                    // if not exists to create it and than procced to work on just created
                    RQMTestSuite testSuite = testPlan.TestSuites.Where(z => z.RQMID == activGroup.TestSuiteId).FirstOrDefault();
                    if ((testSuite != null) && (testSuite.RQMID != null) && (testSuite.URLPathVersioned != null) &&
                        (testSuite.RQMID != string.Empty) && (testSuite.URLPathVersioned != string.Empty))
                    {
                        try
                        {
                            ResultInfo resultInfo;
                            // check if execution record of testSuite exist. If not - to create it
                            if ((testSuite.TestSuiteExecutionRecord == null) || (testSuite.TestSuiteExecutionRecord.RQMID == null) || (testSuite.TestSuiteExecutionRecord.URLPathVersioned == string.Empty))
                            {
                                testSuite.ACL_TestSuite_Copy = new TestSuite();
                                testSuite.ACL_TestSuite_Copy.TestSuiteName     = testSuite.Name;
                                testSuite.ACL_TestSuite_Copy.TestSuiteExportID = testSuite.RQMID;
                                resultInfo = RQMConnect.Instance.RQMRep.CreateTestSuiteExecutionRecord(loginData, RQMCore.ALMProjectGuid, ALMCore.AlmConfig.ALMProjectName, RQMCore.ALMProjectGroupName, testSuite.ACL_TestSuite_Copy, bfExportedID, businessFlow.Name.ToString());

                                if (resultInfo.IsSuccess)
                                {
                                    if (testSuite.TestSuiteExecutionRecord == null)
                                    {
                                        testSuite.TestSuiteExecutionRecord = new RQMTestSuiteExecutionRecord();
                                    }
                                    testSuite.TestSuiteExecutionRecord.RQMID            = testSuite.ACL_TestSuite_Copy.TestSuiteExecutionRecordExportID;
                                    testSuite.TestSuiteExecutionRecord.URLPathVersioned = testSuite.ACL_TestSuite_Copy.TestSuiteExecutionRecordExportUri;
                                }
                            }
                            else
                            {
                                testSuite.ACL_TestSuite_Copy = new TestSuite();
                                testSuite.ACL_TestSuite_Copy.TestSuiteName     = testSuite.Name;
                                testSuite.ACL_TestSuite_Copy.TestSuiteExportID = testSuite.RQMID;
                                testSuite.ACL_TestSuite_Copy.TestSuiteExecutionRecordExportID  = testSuite.TestSuiteExecutionRecord.RQMID;
                                testSuite.ACL_TestSuite_Copy.TestSuiteExecutionRecordExportUri = testSuite.TestSuiteExecutionRecord.URLPathVersioned;
                            }

                            // after creating of execution record at RQM and as object at Ginger (or checking that it's exists)
                            // need to create testsuiteLOG on it and add test caseexecution records on it Ginger (the objects at RQM will be created after loop)
                            ACL_Data_Contract.Activity currentActivity = GetTestCaseFromActivityGroup(activGroup);
                            resultInfo = RQMConnect.Instance.RQMRep.CreateExecutionRecordPerActivityWithInTestSuite(loginData, RQMCore.ALMProjectGuid, ALMCore.AlmConfig.ALMProjectName, RQMCore.ALMProjectGroupName, currentActivity, bfExportedID, businessFlow.Name, testSuite.Name.ToString());
                            if (resultInfo.IsSuccess)
                            {
                                if ((testSuite.TestSuiteExecutionRecord.TestSuiteResults == null) || (testSuite.TestSuiteExecutionRecord.TestSuiteResults.Count == 0) || (testSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult == null))
                                {
                                    testSuite.TestSuiteExecutionRecord.TestSuiteResults       = new ObservableList <RQMTestSuiteResults>();
                                    testSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult = new RQMTestSuiteResults();
                                    testSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult.RQMExecutionRecords = new ObservableList <RQMExecutionRecord>();
                                    testSuite.TestSuiteExecutionRecord.TestSuiteResults.Add(testSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult);
                                }

                                RQMExecutionRecord executionRecord = new RQMExecutionRecord(currentActivity.ExportedTcExecutionRecId.ToString(), currentActivity.ExportedTestScriptId.ToString(), currentActivity.ExportedID.ToString());
                                testSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult.RQMExecutionRecords.Add(executionRecord);
                                testSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult.ACL_TestSuiteLog_Copy.TestSuiteLogExecutionRecords.Add(exeResult);
                                exeResult.ExpectedResultName = currentActivity.EntityName;
                                erExportID = executionRecord.RQMID;
                                currentActivity.ExportedID = long.Parse(executionRecord.RQMID);

                                string atsID = GetExportedIDString(activGroup.ExternalID, "AtsID");
                                if (atsID == "0")
                                {
                                    atsID = string.Empty;
                                }
                                activGroup.ExternalID = "RQMID=" + txExportID + "|RQMScriptID=" + tsExportID + "|RQMRecordID=" + erExportID + "|AtsID=" + atsID;
                            }
                        }
                        catch { }
                    }
                    else
                    {
                    }
                }
                else if (string.IsNullOrEmpty(erExportID) || erExportID.Equals("0") || !testPlan.RQMExecutionRecords.Select(z => z.RQMID).ToList().Contains(erExportID))
                {
                    ResultInfo resultInfo;
                    ACL_Data_Contract.Activity currentActivity = GetTestCaseFromActivityGroup(activGroup);
                    try
                    {
                        // check if executionRecordID exist in RQM but still was not updated in business flow XML
                        RQMExecutionRecord currentExecutionRecord = testPlan.RQMExecutionRecords.Where(y => y.RelatedTestCaseRqmID == txExportID && y.RelatedTestScriptRqmID == tsExportID).ToList().FirstOrDefault();
                        if (currentExecutionRecord != null)
                        {
                            erExportID = currentExecutionRecord.RQMID;
                        }
                        else
                        {
                            // if executionRecord not updated and not exists - so create one in RQM and update BussinesFlow object (this may be not saved due not existed "autosave" functionality)
                            resultInfo = RQMConnect.Instance.RQMRep.CreateExecutionRecordPerActivity(loginData, RQMCore.ALMProjectGuid, ALMCore.AlmConfig.ALMProjectName, RQMCore.ALMProjectGroupName, currentActivity, bfExportedID, businessFlow.Name);
                            if (!currentActivity.ExportedTcExecutionRecId.Equals("0"))
                            {
                                string atsID = GetExportedIDString(activGroup.ExternalID, "AtsID");
                                if (atsID == "0")
                                {
                                    atsID = string.Empty;
                                }
                                erExportID            = currentActivity.ExportedTcExecutionRecId.ToString();
                                activGroup.ExternalID = "RQMID=" + txExportID + "|RQMScriptID=" + tsExportID + "|RQMRecordID=" + erExportID + "|AtsID=" + atsID;
                                ;
                            }
                        }
                    }
                    catch
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Failed to create Execution Record Per Activity - " + currentActivity.EntityName);
                    }
                }
                if (string.IsNullOrEmpty(txExportID) || string.IsNullOrEmpty(tsExportID) || string.IsNullOrEmpty(erExportID) || txExportID.Equals("0") || tsExportID.Equals("0") || erExportID.Equals("0"))
                {
                    result = "At " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + ": " + businessFlow.Name + " " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroup) + ", is missing ExternalID, cannot export RQM TestPlan execution results without Extrnal ID";
                    return(null);
                }
                exeResult.TestCaseExportID        = txExportID;
                exeResult.TestScriptExportID      = tsExportID;
                exeResult.ExecutionRecordExportID = erExportID;

                int i = 1;
                foreach (Activity act in relevantActivities)
                {
                    ExecutionStep exeStep = new ExecutionStep
                    {
                        StepExpResults = act.Expected,
                        StepOrderId    = i,
                        EntityDesc     = act.ActivityName,
                    };
                    i++;

                    switch (act.Status)
                    {
                    case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed:
                        exeStep.StepStatus = ACL_Data_Contract.ExecutoinStatus.Failed;
                        string     errors     = string.Empty;
                        List <Act> failedActs = act.Acts.Where(x => x.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed).ToList();
                        foreach (Act action in failedActs)
                        {
                            errors += action.Error + Environment.NewLine;
                        }
                        exeStep.StepActualResult = errors;
                        break;

                    case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed:
                        exeStep.StepStatus       = ACL_Data_Contract.ExecutoinStatus.Passed;
                        exeStep.StepActualResult = "Passed as expected";
                        break;

                    case Amdocs.Ginger.CoreNET.Execution.eRunStatus.NA:
                        exeStep.StepStatus       = ACL_Data_Contract.ExecutoinStatus.NA;
                        exeStep.StepActualResult = "NA";
                        break;

                    case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Pending:
                        exeStep.StepStatus       = ACL_Data_Contract.ExecutoinStatus.In_Progress;
                        exeStep.StepActualResult = "Was not executed";
                        break;

                    case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Running:
                        exeStep.StepStatus       = ACL_Data_Contract.ExecutoinStatus.In_Progress;
                        exeStep.StepActualResult = "Not Completed";
                        break;

                    case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Skipped:
                        exeStep.StepStatus       = ACL_Data_Contract.ExecutoinStatus.Outscoped;
                        exeStep.StepActualResult = "Skipped";
                        break;

                    case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Blocked:
                        exeStep.StepStatus       = ACL_Data_Contract.ExecutoinStatus.Blocked;
                        exeStep.StepActualResult = "Blocked";
                        break;

                    case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Stopped:
                        exeStep.StepStatus       = ACL_Data_Contract.ExecutoinStatus.Inconclusive;
                        exeStep.StepActualResult = "Stopped";
                        break;
                    }
                    exeResult.ExecutionStep.Add(exeStep);
                }
                return(exeResult);
            }
            catch (Exception ex)
            {
                result = "Unexpected error occurred- " + ex.Message;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to export execution details to RQM/ALM", ex);
                return(null);
            }
        }
예제 #16
0
 internal Wrapper(ExecutionStep step)
 {
     this.value = step;
 }
예제 #17
0
 private void StandbyWhenOff(IState <States> state, ExecutionStep step, States value, Events trigger, object args)
 {
     OnEnter(step, () => {
         Console.WriteLine("In StandbyWhenOff(...) : {0} --{1}-> {2}", value, trigger, this.Value);
     });
 }