Esempio n. 1
0
 public void PrintFinalResults(FinalResultsData data)
 {
     outputWriter.AddFinalScore(data.finalScorePercentage);
     outputWriter.AddTestType(data.isJunior);
     foreach (var feature in data.featureList)
     {
         featData.title           = FeatureTitleStorage.GetFeatureTitle(feature.Feature);
         featData.featureEvidence = feature.Evidence;
         featData.featurePass     = feature.Inconclusive ? (bool?)null : feature.Passed;
         featData.score           = feature.FeatureRating * 100;
         var result = feature.Inconclusive
             ? "Could not perform check"
             : $"Feature implemented: {(feature.Passed ? "Yes" : "No")}";
         featData.featureResult        = result;
         featData.featureHelperMessage = feature.HelperMessage;
         featData.weighting            = feature.FeatureWeighting;
         featData.rawScore             = data.finalScore == 0 ? 0 : Math.Round(feature.WeightedRating / data.finalScore * data.finalScorePercentage, 2);
         outputWriter.AddFeature(featData);
     }
     outputWriter.WriteReport();
 }
Esempio n. 2
0
        private static async Task Main(string[] args)
        {
            var stopwatch = Stopwatch.StartNew();

            AppDomain.CurrentDomain.UnhandledException += ExceptionHandler.CurrentDomain_UnhandledException;

            var commandLineHandler = new CommandLineParser(args);
            var result             = commandLineHandler.Parse();

            const string reportFilename = "YoCodeReport.html";
            var          outputPath     = result.OutputFilePath != null?Path.Combine(result.OutputFilePath, reportFilename) : reportFilename;

            var outputs = new List <IPrint>();

            if (result.CreateHtmlReport)
            {
                outputs.Add(new WebWriter(outputPath));
            }

            outputs.Add(new ConsoleWriter());

            var compositeOutput = new Output(new CompositeWriter(outputs), outputPath, (IErrorReporter)outputs.Find(a => a is ConsoleWriter));

            var appSettingsBuilder = new AppSettingsBuilder(result.JuniorTest);

            var parameters = new RunParameterChecker(compositeOutput, result, appSettingsBuilder);

            if (!parameters.ParametersAreValid())
            {
                if (!result.HelpAsked)
                {
                    compositeOutput.ShowInputErrors(parameters.Errs);
                }
                else
                {
                    compositeOutput.ShowHelp();
                    WebWriter.LaunchReport(result, outputPath);
                }
                return;
            }

            var modifiedTestDirPath = result.InputFilePath;

            var dir = new PathManager(modifiedTestDirPath);

            CancellationTokenSource source = new CancellationTokenSource();

            if (!result.NoLoadingScreen)
            {
                var t = Task.Run(() =>
                {
                    LoadingAnimation.RunLoading(source.Token);
                }, source.Token);
            }

            var checkManager = new CheckManager(new CheckConfig(dir, parameters));

            var evidenceList = await checkManager.PerformChecks();

            var results = new Results(evidenceList, appSettingsBuilder.GetWeightingsPath());

            StopLoadingAnimation(source);

            compositeOutput.PrintFinalResults(new FinalResultsData()
            {
                featureList          = evidenceList.OrderBy(a => FeatureTitleStorage.GetFeatureTitle(a.Feature)),
                isJunior             = result.JuniorTest,
                finalScore           = results.FinalScore,
                finalScorePercentage = results.FinalScorePercentage,
            });

            WebWriter.LaunchReport(result, outputPath);

            Console.WriteLine($"YoCode run time: {stopwatch.Elapsed}");
        }