コード例 #1
0
        public static int Main(string[] args)
        {
            int error = -1;

            if (ArgumentHelper.IsHelpNeeded(args))
            {
                ArgumentHelper.ShowHelp();
            }
            else
            {
                Keyboard.AbortKey = Keys.Pause;
                var silentMode   = ArgumentHelper.IsSilent(args);
                var dialogResult = DialogResult.None;

                string pathToReport = Directory.GetCurrentDirectory() + @"\..\..\Source\Run\Bin\Debug\Report\";
                if (!Directory.Exists(pathToReport))
                {
                    Directory.CreateDirectory(pathToReport);
                }

                string report = pathToReport + "LatestReport.rxlog";

                TestReport.Setup(ReportLevel.Debug, report, true);

                try
                {
                    string configFile = Directory.GetCurrentDirectory() + @"\..\..\Source\Run\Bin\Debug\ConfigData\Configuration.xml";
                    configuratorDialog = new ConfiguratorDialog(configFile);

                    if (!silentMode)
                    {
                        dialogResult = configuratorDialog.ShowDialog();
                    }

                    if (dialogResult == DialogResult.Cancel)
                    {
                        MessageBox.Show(@"Operation was canceled by user.");
                    }
                    else if (dialogResult == DialogResult.OK || silentMode)
                    {
                        LoaderHelper.InitializeAssemblyProvider();
                        ReportHelper.ReportPath = @"C:\Report\Output\";
                        EH.PCPS.TestAutomation.Common.Tools.Logging.Log4Net.Log4NetLog.XmlInitialize();

                        /*----------------*/
                        /* Test Area      */
                        /*----------------*/

                        //EH.PCPS.TestAutomation.Testlibrary.TestCases.DeviceFunction.CoDIA.Parameterization.TC_ConnectToRemoteHost_HMI.Run();
                        //EH.PCPS.TestAutomation.Testlibrary.TestCases.HostApplication.TC_OpenHostApplication.Run(@"C:\Program Files (x86)\Endress+Hauser\FieldCare\Frame\FMPFrame.exe");
                        EH.PCPS.TestAutomation.Testlibrary.TestCases.HostApplication.FDT.TC_FdtPrint.Run(@"C:\Report\Output\Test", 30000);
                    }
                    else
                    {
                        throw new Exception("Impossible error");
                    }
                }
                catch (ImageNotFoundException e)
                {
                    Report.Error(e.ToString());
                    Report.LogData(ReportLevel.Error, "Image not found", e.Feature);
                    Report.LogData(ReportLevel.Error, "Searched image", e.Image);
                    error = -1;
                }
                catch (RanorexException e)
                {
                    Report.Error(e.ToString());
                    Report.Screenshot();
                    error = -1;
                }
                catch (ThreadAbortException e)
                {
                    Report.Warn("AbortKey has been pressed: " + e);
                    Thread.ResetAbort();
                    error = -1;
                }
                catch (Exception e)
                {
                    Report.Error("Unexpected exception occurred: " + e);
                    error = -1;
                }

                Report.End();
                return(error);
            }

            return(0);
        }