Пример #1
0
 public void Document(RunResult result)
 {
     PrintEvil.Document(result, Before, Given.ToArray(), When, _text.ToString());
 }
Пример #2
0
        public static void Document <T>(
            RunResult result,
            List <Expression <Action> > before,
            IEvent <T>[] given,
            ICommand <T> when,
            string decisions) where T : IIdentity
        {
            var passed = result.Passed ? "Passed" : "Failed";

            Console.WriteLine("{0}: {1} - {2}", Extensions.CleanupName(result.FoundOnMemberInfo.DeclaringType.Name), Extensions.CleanupName(result.Name), passed);

            if (before.Any())
            {
                Console.WriteLine();
                Console.WriteLine("Environment: ");
                foreach (var expression in before)
                {
                    PrintAdjusted("  ", PAssert.CreateSimpleFormatFor(expression));
                }
            }

            if (given.Any())
            {
                Console.WriteLine();
                Console.WriteLine("Given:");

                for (int i = 0; i < given.Length; i++)
                {
                    PrintEvil.PrintAdjusted(" " + (i + 1) + ". ", Describe.Object(given[i]).Trim());
                }
            }


            if (when != null)
            {
                Console.WriteLine();
                PrintAdjusted("When: ", Describe.Object(when).Trim());
            }

            Console.WriteLine();
            Console.WriteLine("Expectations:");
            foreach (var expecation in result.Expectations)
            {
                PrintAdjusted("  " + (expecation.Passed ? "[Passed]" : "[Failed]") + " ", expecation.Text.Trim());
                if (!expecation.Passed && expecation.Exception != null)
                {
                    PrintAdjusted("             ", expecation.Exception.Message);
                }
            }



            if (result.Thrown != null)
            {
                Console.WriteLine("Specification failed: " + result.Message.Trim());
                Console.WriteLine();
                Console.WriteLine(result.Thrown);
            }

            if (decisions.Length > 0)
            {
                Console.WriteLine("");
                Console.WriteLine("Decisions made:");
                PrintAdjusted("  ", decisions.ToString());
            }

            Console.WriteLine(new string('-', 80));
            Console.WriteLine();
        }