コード例 #1
0
        /// <summary>
        /// Checks to see if this options block has all the required properties (or that we had values in the settings for them)
        /// </summary>
        /// <returns></returns>
        public override bool HasRequiredProperties(out string[] missingArguments)
        {
            if (string.IsNullOrEmpty(this.DocumentationSetPath))
            {
                this.DocumentationSetPath = Environment.CurrentDirectory;
            }

            FancyConsole.WriteLine("Documentation path: " + this.DocumentationSetPath);

            missingArguments = new string[0];
            return(true);
        }
コード例 #2
0
        public static async Task FinishTestAsync(string testName, TestOutcome outcome, string message = null, string filename = null, string stdOut = null, bool printFailuresOnly = false)
        {
            var endTime = DateTimeOffset.Now.Ticks;

            TimeSpan duration;
            long     startTime;

            if (TestStartTimes.TryGetValue(testName, out startTime))
            {
                duration = new TimeSpan(endTime - startTime);
                TestStartTimes.Remove(testName);
            }
            else
            {
                duration = TimeSpan.Zero;
            }

            if (null == filename)
            {
                TestStartFilename.TryGetValue(testName, out filename);
                TestStartFilename.Remove(testName);
            }

            if (!printFailuresOnly || outcome != TestOutcome.Passed)
            {
                FancyConsole.Write("Test {0} complete.", testName);
                switch (outcome)
                {
                case TestOutcome.Failed:
                    FancyConsole.Write(ConsoleColor.Red, " Failed: {0}", message);
                    break;

                case TestOutcome.Passed:
                    FancyConsole.Write(ConsoleColor.Green, " Passed: {0}", message);
                    break;

                default:
                    FancyConsole.Write(" {0}: {1}", outcome, message);
                    break;
                }
                FancyConsole.WriteLine(" duration: {0}", duration);
            }

            await BuildWorkerApi.RecordTestAsync(testName, TestFrameworkName, outcome : outcome, durationInMilliseconds : (long)duration.TotalMilliseconds, errorMessage : message, filename : filename, stdOut : stdOut);
        }
コード例 #3
0
ファイル: CheckResults.cs プロジェクト: rgregg/apidoctor
        public void PrintToConsole(bool addNewLine = true)
        {
            if (addNewLine)
            {
                FancyConsole.WriteLine();
                FancyConsole.Write("Runs completed. ");
            }

            const string percentCompleteFormat = "{0:0.00}% passed";

            FancyConsole.Write(
                this.PercentSuccessful == 100.0 ? FancyConsole.ConsoleSuccessColor : FancyConsole.ConsoleWarningColor,
                percentCompleteFormat,
                this.PercentSuccessful);

            if (this.FailureCount > 0 || this.WarningCount > 0)
            {
                FancyConsole.Write(" (");
                if (this.FailureCount > 0)
                {
                    FancyConsole.Write(FancyConsole.ConsoleErrorColor, "{0} errors", this.FailureCount);
                }
                if (this.WarningCount > 0 && this.FailureCount > 0)
                {
                    FancyConsole.Write(", ");
                }
                if (this.WarningCount > 0)
                {
                    FancyConsole.Write(FancyConsole.ConsoleWarningColor, "{0} warnings", this.WarningCount);
                }
                if ((this.WarningCount > 0 || this.FailureCount > 0) && this.SuccessCount > 0)
                {
                    FancyConsole.Write(", ");
                }
                if (this.SuccessCount > 0)
                {
                    FancyConsole.Write(FancyConsole.ConsoleSuccessColor, "{0} successful", this.SuccessCount);
                }
                FancyConsole.Write(")");
            }
            FancyConsole.WriteLine();
        }
コード例 #4
0
        public override bool HasRequiredProperties(out string[] missingArguments)
        {
            string[] baseResults;
            if (!base.HasRequiredProperties(out baseResults))
            {
                missingArguments = baseResults;
                return(false);
            }

            List <string> missingArgs = new List <string>();

            if (this.Format == PublishFormat.Mustache)
            {
                if (string.IsNullOrEmpty(this.TemplatePath))
                {
                    missingArgs.Add("template");
                }
            }
            if (this.Format == PublishFormat.Swagger2)
            {
                if (string.IsNullOrEmpty(this.Title))
                {
                    missingArgs.Add("swagger-title");
                }
                if (string.IsNullOrEmpty(this.Description))
                {
                    missingArgs.Add("swagger-description");
                }
                if (string.IsNullOrEmpty(this.Version))
                {
                    missingArgs.Add("swagger-version");
                }
            }

            missingArguments = missingArgs.ToArray();
            FancyConsole.WriteLine(ConsoleColor.Red, $"Missing arguments: {string.Join(",", missingArguments)}");
            return(missingArgs.Count == 0);
        }
コード例 #5
0
        public static void StartTest(string testName, string filename = null, bool skipPrintingHeader = false)
        {
            if (!skipPrintingHeader)
            {
                FancyConsole.WriteLine();
                FancyConsole.Write(FancyConsole.ConsoleHeaderColor, "Starting test: ");
                FancyConsole.Write(FancyConsole.ConsoleDefaultColor, testName);
            }

            if (null != filename)
            {
                if (!skipPrintingHeader)
                {
                    FancyConsole.Write(" [{0}]", filename);
                }
                TestStartFilename[testName] = filename;
            }
            if (!skipPrintingHeader)
            {
                FancyConsole.WriteLine();
            }

            TestStartTimes[testName] = DateTimeOffset.Now.Ticks;
        }