コード例 #1
0
        protected override void WriteErrorMethod030ChangeTimeoutSettings(PSCmdletBase cmdlet, bool terminating)
        {
            // set the Turbo timeout
            if ((!(cmdlet is HasTimeoutCmdletBase)) || (cmdlet as HasTimeoutCmdletBase) == null)
            {
                return;
            }
            if (!terminating ||
                ((null != CurrentData.LastResult || null != CurrentData.CurrentWindow) &&
                 (null != CurrentData.LastResult || !((HasTimeoutCmdletBase)cmdlet).IsCritical)))
            {
                return;
            }
            if (Preferences.TimeoutSetByCustomer != (true &&
                                                     0 == Preferences.StoredDefaultTimeout))
            {
                return;
            }
            int timeoutToStore = Preferences.Timeout;

            Preferences.Timeout = Preferences.AfterFailTurboTimeout;
            Preferences.TimeoutSetByCustomer = false;
            Preferences.StoredDefaultTimeout = timeoutToStore;

            WriteVerbose(this, "Preferences.StoredDefaultTimeout = " + Preferences.StoredDefaultTimeout);
        }
コード例 #2
0
 protected override void WriteSingleObject(PSCmdletBase cmdlet, object outputObject)
 {
     try {
         base.WriteObject(outputObject);
     }
     catch {}
 }
コード例 #3
0
 protected void WriteObjectMethod030RunScriptBlocks(PSCmdletBase cmdlet, object outputObject)
 {
     // 20140113
     try {
         WriteVerbose(this, "is going to run scriptblocks");
         if (cmdlet == null)
         {
             return;
         }
         // run scriptblocks
         if (!(cmdlet is HasScriptBlockCmdletBase))
         {
             return;
         }
         WriteVerbose(this, "cmdlet is of the HasScriptBlockCmdletBase type");
         if (outputObject == null)
         {
             WriteVerbose(this, "run OnError script blocks (null)");
             RunOnErrorScriptBlocks(((HasScriptBlockCmdletBase)cmdlet), null);
         }
         else if (outputObject is bool && ((bool)outputObject) == false)
         {
             WriteVerbose(this, "run OnError script blocks (false)");
             RunOnErrorScriptBlocks(((HasScriptBlockCmdletBase)cmdlet), null);
         }
         else
         {
             WriteVerbose(this, "run OnSuccess script blocks");
             RunOnSuccessScriptBlocks(((HasScriptBlockCmdletBase)cmdlet), null);
         }
     }
     catch {}
 }
コード例 #4
0
        protected override void WriteErrorMethod060OutputError(PSCmdletBase cmdlet, ErrorRecord errorRecord, bool terminating)
        {
            if (terminating)
            {
                //this.WriteVerbose(this, "terminating error !!!");
                try {
                    // 20130430
                    WriteLog(LogLevels.Fatal, errorRecord);

                    ThrowTerminatingError(errorRecord);
                }
                catch {}
            }
            else
            {
                //this.WriteVerbose(this, "regular error !!!");
                try {
                    // 20130430
                    WriteLog(LogLevels.Error, errorRecord);

                    WriteError(errorRecord);
                }
                catch {}
            }
        }
コード例 #5
0
 protected override void WriteSingleObject(PSCmdletBase cmdlet, object outputObject)
 {
     //WriteVerbose(this, " Moq");
     try {
         base.WriteObject(outputObject);
     }
     catch {}
 }
コード例 #6
0
 protected override void WriteSingleObject(PSCmdletBase cmdlet, object outputObject)
 {
     //WriteVerbose(this, " TMX");
     try {
         // 20140314
         // base.WriteObject(outputObject);
         WriteObject(outputObject);
     }
     catch {}
 }
コード例 #7
0
        protected void WriteObjectMethod040SetTestResult(PSCmdletBase cmdlet, object outputObject)
        {
            if (cmdlet == null)
            {
                return;
            }
            try {
                CurrentData.LastResult = outputObject;

                var iInfo = string.Empty;
                if (!string.IsNullOrEmpty(((HasScriptBlockCmdletBase)cmdlet).TestResultName))
                {
                    TmxHelper.CloseTestResult(((HasScriptBlockCmdletBase)cmdlet).TestResultName,
                                              ((HasScriptBlockCmdletBase)cmdlet).TestResultId,
                                              ((HasScriptBlockCmdletBase)cmdlet).TestPassed,
                                              ((HasScriptBlockCmdletBase)cmdlet).KnownIssue, //false, // isKnownIssue
                                                                                             // 20160116
                                                                                             // MyInvocation,
                                              null,                                          // Error
                                              string.Empty,
                                              TestResultOrigins.Logical,
                                              true);
                }
                else
                {
                    if (!Preferences.EveryCmdletAsTestResult)
                    {
                        return;
                    }
                    ((HasScriptBlockCmdletBase)cmdlet).TestResultName =
                        GetGeneratedTestResultNameByPosition(
                            MyInvocation.Line,
                            MyInvocation.PipelinePosition);
                    ((HasScriptBlockCmdletBase)cmdlet).TestResultId = string.Empty;
                    ((HasScriptBlockCmdletBase)cmdlet).TestPassed   = true;

                    TmxHelper.CloseTestResult(((HasScriptBlockCmdletBase)cmdlet).TestResultName,
                                              string.Empty,                                  //((HasScriptBlockCmdletBase)cmdlet).TestResultId, // empty, to be generated
                                              ((HasScriptBlockCmdletBase)cmdlet).TestPassed,
                                              ((HasScriptBlockCmdletBase)cmdlet).KnownIssue, //false, // isKnownIssue
                                                                                             // 20160116
                                                                                             // MyInvocation,
                                              null,                                          // Error
                                              string.Empty,
                                              TestResultOrigins.Automatic,
                                              false);
                }
            }
            catch (Exception) {
                WriteVerbose(this, "for working with test results you need to import the TMX module");
            }
        }
コード例 #8
0
        protected override void WriteErrorMethod070Report(PSCmdletBase cmdlet)
        {
//            if (Preferences.AutoLog) {
//
//                string reportString =
//                    CmdletSignature(((CommonCmdletBase)cmdlet));
//
//                reportString +=
//
//
//                this.WriteLog(LogLevels.Info, reportString);
//            }
        }
コード例 #9
0
        protected override void WriteErrorMethod060OutputError(PSCmdletBase cmdlet, ErrorRecord err, bool terminating)
        {
            if (terminating)
            {
                WriteLog(LogLevels.Fatal, err);

                ThrowTerminatingError(err);
            }
            else
            {
                WriteLog(LogLevels.Error, err);

                WriteError(err);
            }
        }
コード例 #10
0
        protected void WriteObjectMethod045OnSuccessScreenshot(PSCmdletBase cmdlet, object outputObject)
        {
            WriteVerbose(this, "WriteObjectMethod045OnSuccessScreenshot UIAutomation");

            if (Preferences.OnSuccessScreenShot)
            {
                UiaHelper.GetScreenshotOfAutomationElement(
                    (cmdlet as HasControlInputCmdletBase),
                    (outputObject as IUiElement),
                    CmdletName(cmdlet),
                    true,
                    new ScreenshotRect(),
                    string.Empty,
                    Preferences.OnSuccessScreenShotFormat);
            }
        }
コード例 #11
0
        protected override void WriteSingleObject(PSCmdletBase cmdlet, object outputObject)
        {
            WriteObjectMethod020Highlight(cmdlet, outputObject);

            WriteObjectMethod030RunScriptBlocks(cmdlet, outputObject);

            WriteObjectMethod040SetTestResult(cmdlet, outputObject);

            WriteObjectMethod045OnSuccessScreenshot(cmdlet, outputObject);

            WriteObjectMethod050OnSuccessDelay(cmdlet, outputObject);

            WriteObjectMethod060OutputResult(cmdlet, outputObject);

            WriteObjectMethod070Report(cmdlet, outputObject);
        }
コード例 #12
0
        protected override void WriteErrorMethod045OnErrorScreenshot(PSCmdletBase cmdlet)
        {
            //WriteVerbose(this, "WriteErrorMethod045OnErrorScreenshot Moq");
//            if (SePSX.Preferences.OnErrorScreenShot) {
//                UIAutomation.UiaHelper.GetDesktopScreenshot(
//                    this,
//                    string.Empty,
//                    true,
//                    0,
//                    0,
//                    0,
//                    0,
//                    string.Empty,
//                    SePSX.Preferences.OnErrorScreenShotFormat);
//            }
        }
コード例 #13
0
        // 20131114
        protected override void WriteSingleError(PSCmdletBase cmdlet, ErrorRecord errorRecord, bool terminating)
        {
            WriteErrorMethod010RunScriptBlocks(cmdlet);

            WriteErrorMethod020SetTestResult(cmdlet, errorRecord);

            WriteErrorMethod030ChangeTimeoutSettings(cmdlet, terminating);

            WriteErrorMethod040AddErrorToErrorList(cmdlet, errorRecord);

            WriteErrorMethod045OnErrorScreenshot(cmdlet);

            WriteErrorMethod050OnErrorDelay(cmdlet);

            WriteErrorMethod060OutputError(cmdlet, errorRecord, terminating);

            WriteErrorMethod070Report(cmdlet);
        }
コード例 #14
0
        protected override void WriteSingleObject(PSCmdletBase cmdlet, object outputObject)
        {
            //WriteVerbose(this, " TAMS");
            try {
                base.WriteObject(outputObject);

                if (Preferences.AutoLog)
                {
                    string reportString =
                        CmdletSignature(((CommonCmdletBase)cmdlet));

                    reportString +=
                        outputObject.ToString();

                    WriteLog(LogLevels.Info, reportString);
                }
            }
            catch {}
        }
コード例 #15
0
 protected override void WriteErrorMethod060OutputError(PSCmdletBase cmdlet, ErrorRecord errorRecord, bool terminating)
 {
     if (terminating)
     {
         WriteVerbose(this, "terminating error !!!");
         try {
             ThrowTerminatingError(errorRecord);
         }
         catch {}
     }
     else
     {
         WriteVerbose(this, "regular error !!!");
         try {
             WriteError(errorRecord);
         }
         catch {}
     }
 }
コード例 #16
0
        protected override void WriteSingleObject(PSCmdletBase cmdlet, object outputObject)
        {
            WriteVerbose(this, " ESXiMgmt");
            try {
                base.WriteObject(outputObject);

//                if (Preferences.AutoLog) {
//
//                    string reportString =
//                        CmdletSignature(((CommonCmdletBase)cmdlet));
//
//                    reportString +=
//
//
//                    this.WriteLog(LogLevels.Info, reportString);
//                }
            }
            catch {}
        }
コード例 #17
0
        protected override void WriteErrorMethod010RunScriptBlocks(PSCmdletBase cmdlet)
        {
            if (cmdlet == null)
            {
                return;
            }
            // run scriptblocks
            var hasScriptBlockCmdletBase = cmdlet as HasScriptBlockCmdletBase;

            if (hasScriptBlockCmdletBase != null)
            {
                RunOnErrorScriptBlocks(hasScriptBlockCmdletBase, null);
            }

            /*
             * if (cmdlet is HasScriptBlockCmdletBase) {
             *
             *  RunOnErrorScriptBlocks(((HasScriptBlockCmdletBase)cmdlet), null);
             * }
             */
        }
コード例 #18
0
        protected override void WriteErrorMethod045OnErrorScreenshot(PSCmdletBase cmdlet)
        {
            WriteVerbose(this, "WriteErrorMethod045OnErrorScreenshot UIAutomation");

            if (!Preferences.OnErrorScreenShot)
            {
                return;
            }

            IUiElement elementToTakeScreenShot = null;

            try {
                if (null != CurrentData.CurrentWindow)
                {
                    cmdlet.WriteVerbose(cmdlet, "taking screenshot of the current window");
                    elementToTakeScreenShot = CurrentData.CurrentWindow;
                }
                else
                {
                    cmdlet.WriteVerbose(cmdlet, "taking screenshot of the desktop object");
                    elementToTakeScreenShot = UiElement.RootElement;
                }
            }
            catch {
                cmdlet.WriteVerbose(cmdlet, "taking screenshot of the desktop object (on fail)");
                elementToTakeScreenShot = UiElement.RootElement;
            }

            cmdlet.WriteVerbose(cmdlet, "taking screenshot");
            UiaHelper.GetScreenshotOfAutomationElement(
                cmdlet,
                elementToTakeScreenShot,
                CmdletName(cmdlet),
                true,
                new ScreenshotRect(),
                string.Empty,
                Preferences.OnErrorScreenShotFormat);

            cmdlet.WriteVerbose(cmdlet, "done");
        }
コード例 #19
0
 protected void WriteObjectMethod060OutputResult(PSCmdletBase cmdlet, object outputObject)
 {
     WriteVerbose(this, "outputting the result object");
     if (cmdlet == null)
     {
         return;
     }
     try {
         var element = outputObject as IUiElement;
         WriteVerbose(this, "getting the element again to ensure that it still exists");
         if (!(cmdlet is WizardCmdletBase) &&
             (null != element))
         {
             WriteVerbose(this, "returning the object");
             WriteObject((IUiElement)outputObject);
         }
         else if ((cmdlet is WizardCmdletBase))
         {
             WriteVerbose(this, "returning the wizard or step");
             WriteObject(outputObject);
         }
         else
         {
             WriteVerbose("returning as is");
             // 20131204
             HighlighterGeneration++;
             WriteObject(outputObject);
         }
     } catch { // (Exception eeeee) {
         // test
         // 20131109
         //this.WriteVerbose(this, "failed to issue the result object of AutomationElement type");
         WriteVerbose(this, "failed to issue the result object of IUiElement type");
         WriteVerbose(this, "returning as is");
         // 20131204
         HighlighterGeneration++;
         WriteObject(outputObject);
     }
 }
コード例 #20
0
        protected void WriteObjectMethod050OnSuccessDelay(PSCmdletBase cmdlet, object outputObject)
        {
            //System.Threading.Thread.Sleep(Preferences.OnSuccessDelay);
            if (cmdlet != null)
            {
                // remove the Turbo timeout
                if ((cmdlet as HasTimeoutCmdletBase) != null)
                {
                    WriteVerbose(this, "cmdlet as HasTimeoutCmdletBase");

                    if ((CurrentData.CurrentWindow != null &&
                         CurrentData.LastResult != null) ||

                        (outputObject as IUiElement) != null)
                    {
                        WriteVerbose(this, "(CurrentData.CurrentWindow != null && " +
                                     "CurrentData.LastResult != null) || " +
                                     "(outputObject as IUiElement) != null");

                        if (Preferences.StoredDefaultTimeout != 0)
                        {
                            WriteVerbose(this, "Preferences.StoredDefaultTimeout != 0");

                            if (!Preferences.TimeoutSetByCustomer)
                            {
                                WriteVerbose(this, "! Preferences.TimeoutSetByCustomer");

                                Preferences.Timeout = Preferences.StoredDefaultTimeout;

                                Preferences.StoredDefaultTimeout = 0;
                            }
                        }
                    }
                }
            }
            WriteVerbose(this, "sleeping if sleep time is provided");
            Thread.Sleep(Preferences.OnSuccessDelay);
        }
コード例 #21
0
 protected override void WriteErrorMethod050OnErrorDelay(PSCmdletBase cmdlet)
 {
     //this.WriteVerbose(this, " TestUtils");
 }
コード例 #22
0
 protected override void WriteErrorMethod045OnErrorScreenshot(PSCmdletBase cmdlet)
 {
     //WriteVerbose(this, "WriteErrorMethod045OnErrorScreenshot Data");
 }
コード例 #23
0
 protected override void WriteErrorMethod040AddErrorToErrorList(PSCmdletBase cmdlet, ErrorRecord errorRecord)
 {
     //this.WriteVerbose(this, " TestUtils");
 }
コード例 #24
0
 protected override void WriteErrorMethod030ChangeTimeoutSettings(PSCmdletBase cmdlet, bool terminating)
 {
     //this.WriteVerbose(this, " TestUtils");
 }
コード例 #25
0
 protected override void BeforeWriteCollection(PSCmdletBase cmdlet, object[] outputObjectCollection)
 {
 }
コード例 #26
0
 protected override void WriteErrorMethod070Report(PSCmdletBase cmdlet)
 {
     //this.WriteVerbose(this, " TestUtils");
 }
コード例 #27
0
 protected override bool CheckSingleObject(PSCmdletBase cmdlet, object outputObject)
 {
     return(true);
 }
コード例 #28
0
 protected override void WriteErrorMethod010RunScriptBlocks(PSCmdletBase cmdlet)
 {
     //this.WriteVerbose(this, " TestUtils");
 }
コード例 #29
0
 protected override void BeforeWriteCollection(PSCmdletBase cmdlet, System.Collections.Generic.List <object> outputObjectCollection)
 {
 }
コード例 #30
0
 protected override void WriteErrorMethod020SetTestResult(PSCmdletBase cmdlet, ErrorRecord errorRecord)
 {
     //this.WriteVerbose(this, " TestUtils");
 }