Esempio n. 1
0
        public void Asset_Test__FromFolder_TestingScripts_Subfolder_Test1()
        {
            string baseFolder = GetTestingScriptsFolder();

            if (Directory.Exists(baseFolder) == false)
            {
                Assert.True(false, "Unable to find folder");
            }
            else
            {
                Xteq5Runner runner = new Xteq5Runner();

                Task<Report> task = runner.RunAsync(baseFolder);
                Report result = task.Result;

                Assert.True(result.Assets.Count > 15, "<15 assets found");

                //Perform conistentcheck on all members
                foreach (AssetRecord asset in result.Assets)
                {
                    FieldsAreNotNull(asset);
                    ConclusionIsConsistent(asset);
                    ConclusionMatchesOtherFields(asset);
                }

            }
        }
Esempio n. 2
0
        /// <summary>
        /// Generates the report and (if set) the file report
        /// </summary>
        /// <param name="progressRunner">Report status using this Progress object</param>
        /// <returns>TRUE if execution was successful</returns>
        public async Task <bool> RunAsync(IProgress <RunnerProgressDetail> progressRunner = null, IProgress <ReportCreationProgress> progressReportCreation = null)
        {
            ClearRunVariables();

            bool successful = false;

            try
            {
                //Let Xteq5Runner do it's thing...
                Xteq5Runner runner = new Xteq5Runner();
                this.Report = await runner.RunAsync(_compilationPath, progressRunner);

                this.Report.UserText = _userText;

                //MTH: That a second progress is used here is because I know at least one AV software that gets crazy when an unknown EXE saves an HTML file with <script> tags in it.
                //I don't know why, but the report creation takes AGES / A VERY LONG TIME / F**** BAZILLION SECONDS with that POS software installed.
                if (_reportFormat != OutputFormatEnum.Unknown)
                {
                    ProgressReporter <ReportCreationProgress> reporterStart = new ProgressReporter <ReportCreationProgress>(progressReportCreation);
                    reporterStart.Content.Action = ReportAction.Starting;
                    reporterStart.Report();


                    //Generate the report
                    this.ReportFilepath = OutputGenerator.GenerateReportOutputFile(this.Report, _reportFormat, _destFilename);


                    ProgressReporter <ReportCreationProgress> reporterEnd = new ProgressReporter <ReportCreationProgress>(progressReportCreation);
                    reporterEnd.Content.Action = ReportAction.Ended;
                    reporterEnd.Report();
                }

                successful = true;
            }

            catch (FileNotFoundException fnfe)
            {
                //In most cases this means we couldn't load System.Management.Automation.
                if (fnfe.Message.Contains("System.Management.Automation"))
                {
                    //We need to explain to the user that this means PowerShell is missing.
                    this.FailedMessage = "PowerShell is required, but could not be loaded. Please re-run Setup and follow the provided link to install it.";
                }
                else
                {
                    //In any other case we have no idea what is missing, so use the message from the exception.
                    this.FailedMessage = fnfe.Message;
                }

                this.FailedException = fnfe;
            }
            catch (CompilationFolderException cfnfe)
            {
                //The given compilation folder was not found.
                this.FailedMessage   = "The selected compilation folder does not exist";
                this.FailedException = cfnfe;
            }
            catch (CompilationSubFolderException csfnfe)
            {
                //A sub folder was not found.
                this.FailedMessage   = "A required subfolder of the selected compilation folder does not exist";
                this.FailedException = csfnfe;
            }
            catch (PSTestFailedException pstfe)
            {
                //The powershell test failed
                this.FailedMessage   = "Testing the PowerShell environment failed. ";
                this.FailedException = pstfe;
            }
            catch (TemplateFileNotFoundException tfnfe)
            {
                //Template file does not exist in folder
                this.FailedMessage   = "The template file for the report is missing. Please re-run Setup to install it.";
                this.FailedException = tfnfe;
            }
            catch (WMITestException wmite)
            {
                //WMI Test has failed
                this.FailedMessage   = "The Windows Management Instrumentation (WMI) test failed which indicates WMI needs repair. Please search the internet for REPAIR WMI how to do this.";
                this.FailedException = wmite;
            }
            catch (Exception exc)
            {
                //No idea what happened. Use the message from the exception.
                this.FailedMessage   = exc.Message;
                this.FailedException = exc;
            }


            if (successful)
            {
                this.ExecutionSuccessful = true;
                this.FailedMessage       = "";
                this.FailedException     = null;
                return(true);
            }
            else
            {
                this.ExecutionSuccessful = false;
                return(false);
            }
        }