Ejemplo n.º 1
0
        public static void Print(RunResult result, TextWriter output)
        {
            var passed = result.Passed ? "Passed" : "Failed";
            output.WriteLine(result.Name.Replace('_', ' ') + " - " + passed);
            if (result.Thrown != null)
            {
                output.WriteLine();
                output.WriteLine("Specification threw an exception.");
                output.WriteLine(result.Thrown);
                output.WriteLine();
                return;
            }
            var @on = result.GetOnResult();
            if (@on != null)
            {
                output.WriteLine();
                output.WriteLine("On:");
                output.WriteLine(NicePrint(@on));
                output.WriteLine();
            }
            if (result.Result != null)
            {
                output.WriteLine();
                output.WriteLine("Results with:");
                if (result.Result is Exception)
                    output.WriteLine(result.Result.GetType() + "\n" + ((Exception) result.Result).Message);
                else
                    output.WriteLine(NicePrint(result.Result));
                output.WriteLine();
            }

            output.WriteLine("Expectations:");
            foreach (var expecation in result.Expectations)
            {
                if (expecation.Passed)
                    output.WriteLine("\t" + expecation.Text + " " + (expecation.Passed ? "Passed" : "Failed"));
                else
                    output.WriteLine(expecation.Exception.Message);
            }
            if (result.Thrown != null)
            {
                output.WriteLine("Specification failed: " + result.Message);
                output.WriteLine();
                output.WriteLine(result.Thrown);
            }
            output.WriteLine(new string('-', 80));
            output.WriteLine();

            output.Flush();
        }
Ejemplo n.º 2
0
        private static string Format(RunResult result)
        {
            var ret = "\n\n*** SPECIFICATION: " + (result.SpecificationName ?? result.FoundOnMemberInfo.Name) + " ";

            ret += (result.Passed ? "PASSED" : "FAILED") + " " + result.Message + "\n\n";
            if (result.Thrown != null)
                ret += result.Thrown + "\n\n";

            ret += "ON:\n--\n";

            var on = result.GetOnResult();
            if (on != null)
            {
                ret += on.ToString();
            }

            if (result.Result != null)
            {

                ret += ("\nResults with:\n");
                if (result.Result is Exception)
                    ret += (result.Result.GetType() + "\n" + ((Exception)result.Result).Message);
                else
                    ret += (result.Result.ToString());

                ret += "\n";
            }

            ret += "\nEXPECTATIONS:\n-------------\n";

            foreach (var exp in result.Expectations)
            {
                if (!exp.Passed)
                    ret += "\n<<<----------\n";

                ret += exp.Text + " " + (exp.Passed ? "PASSED" : "FAILED") + "\n";

                if (!exp.Passed)
                {
                    ret += PadMultiLineText(exp.Exception.Message) + "\n\n";
                    ret += "\t>>>----------\n\n";
                }
            }

            return ret;
        }
Ejemplo n.º 3
0
 private static void PrintSpec(RunResult result)
 {
     var passed = result.Passed ? "Passed" : "Failed";
     Console.WriteLine(result.Name.Replace('_', ' ') + " - " +passed);
     var on = result.GetOnResult();
         if(on != null)
         {
             Console.WriteLine();
             Console.WriteLine("On:");
             Console.WriteLine(on.ToString());
             Console.WriteLine();
         }
         if (result.Result != null)
         {
             Console.WriteLine();
             Console.WriteLine("Results with:");
             if(result.Result is Exception)
                 Console.WriteLine(result.Result.GetType() + "\n" + ((Exception) result.Result).Message );
             else
                 Console.WriteLine(result.Result.ToString());
             Console.WriteLine();
         }
     
     Console.WriteLine("Expectations:");
     foreach(var expecation in result.Expectations)
     {
         if(expecation.Passed)
             Console.WriteLine("\t" + expecation.Text + " " + (expecation.Passed ? "Passed" : "Failed"));
         else
             Console.WriteLine(expecation.Exception.Message);
     }
     if(result.Thrown != null)
     {
         Console.WriteLine("Specification failed: " + result.Message);
         Console.WriteLine();
         Console.WriteLine(result.Thrown);
     }
     Console.WriteLine(new string('-', 80));
     Console.WriteLine();
 	Console.ReadLine();
 }
        private void FormatRunResultBody(RunResult result)
        {
            if (result.Thrown != null)
            {
                output.WriteLine("Specification threw an exception.");
                output.WriteLine(result.Thrown);
                output.WriteLine();
                return;
            }
            var @on = result.GetOnResult();
            if (@on != null)
            {
                output.WriteLine("On:");
                output.WriteLine(SpecificationPrinter.NicePrint(@on));
                output.WriteLine();
            }
            if (result.Result != null)
            {
                output.WriteLine("Results with:");
                if (result.Result is Exception)
                    output.WriteLine(result.Result.GetType() + "\n" + ((Exception)result.Result).Message);
                else
                    output.WriteLine(SpecificationPrinter.NicePrint(result.Result));
                output.WriteLine();
            }

            output.WriteLine("Expectations:");
            foreach (var expecation in result.Expectations)
            {
                if (expecation.Passed)
                    output.WriteLine("\t" + expecation.Text + " " + (expecation.Passed ? "Passed" : "Failed"));
                else
                    output.WriteLine(expecation.Exception.Message);
            }
            if (result.Thrown != null)
            {
                output.WriteLine("Specification failed: " + result.Message);
                output.WriteLine();
                output.WriteLine(result.Thrown);
            }
        }