Esempio n. 1
0
 public string Summary( ContextCollection contexts )
 {
     return "{0} Examples, {1} Failed, {2} Pending".With(
         contexts.Examples().Count(),
         contexts.Failures().Count(),
         contexts.Pendings().Count()
     );
 }
Esempio n. 2
0
 public string Summary(ContextCollection contexts)
 {
     return("{0} Examples, {1} Failed, {2} Pending".With(
                contexts.Examples().Count(),
                contexts.Failures().Count(),
                contexts.Pendings().Count()
                ));
 }
Esempio n. 3
0
        public string Summary(ContextCollection contexts)
        {
            var summary = "{0} Examples, {1} Failed, {2} Pending".With(
                contexts.Examples().Count(),
                contexts.Failures().Count(),
                contexts.Pendings().Count()
                );

            if (contexts.AnyTaggedWithFocus())
            {
                summary += Environment.NewLine + Environment.NewLine + @"NSpec found context/examples tagged with ""focus"" and only ran those.";
            }

            return(summary);
        }
Esempio n. 4
0
        public string Summary(ContextCollection contexts)
        {
            var summary = "{0} Examples, {1} Failed, {2} Pending".With(
                contexts.Examples().Count(),
                contexts.Failures().Count(),
                contexts.Pendings().Count()
                );

            if (contexts.AnyTaggedWithFocus())
            {
                summary += Environment.NewLine + Environment.NewLine + @"NSpec found context/examples tagged with ""focus"" and only ran those.";
            }

            return summary;
        }
Esempio n. 5
0
        public void Write(ContextCollection contexts)
        {
            StringBuilder sb  = new StringBuilder();
            StringWriter  sw  = new StringWriter(sb);
            XmlTextWriter xml = new XmlTextWriter(sw);

            xml.WriteStartElement("testsuites");
            xml.WriteAttributeString("tests", contexts.Examples().Count().ToString());
            xml.WriteAttributeString("errors", "0");
            xml.WriteAttributeString("failures", contexts.Failures().Count().ToString());
            xml.WriteAttributeString("skip", contexts.Pendings().Count().ToString());

            contexts.Do(c => this.BuildContext(xml, c));
            xml.WriteEndElement();

            Console.WriteLine(sb.ToString());
        }
Esempio n. 6
0
        public void Write(ContextCollection contexts)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            XmlTextWriter xml = new XmlTextWriter(sw);

            xml.WriteStartElement("testsuites");
            xml.WriteAttributeString("tests", contexts.Examples().Count().ToString());
            xml.WriteAttributeString("errors", "0");
            xml.WriteAttributeString("failures", contexts.Failures().Count().ToString());
            xml.WriteAttributeString("skip", contexts.Pendings().Count().ToString());

            contexts.Do(c => this.BuildContext(xml, c));
            xml.WriteEndElement();

            Console.WriteLine(sb.ToString());
        }
Esempio n. 7
0
        public string Summary(ContextCollection contexts)
        {
            var condition = new Func <ExampleBase, bool>(t => ExamplesToProcess.Count == 0 || ExamplesToProcess.Contains(GetSpecName(t)));

            var summary = "{0} Examples, {1} Failed, {2} Pending".With(
                contexts.Examples().Where(condition).Count(),
                contexts.Failures().Where(condition).Count(),
                contexts.Pendings().Where(condition).Count()
                );

            if (contexts.AnyTaggedWithFocus())
            {
                summary += "\n" + "\n" + @"NSpec found context/examples tagged with ""focus"" and only ran those.";
            }

            return(summary);
        }
Esempio n. 8
0
        public void Write(ContextCollection contexts)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            XmlTextWriter xml = new XmlTextWriter(sw);

            xml.WriteStartElement("Contexts");
            xml.WriteAttributeString("TotalSpecs", contexts.Examples().Count().ToString());
            xml.WriteAttributeString("TotalFailed", contexts.Failures().Count().ToString());
            xml.WriteAttributeString("TotalPending", contexts.Pendings().Count().ToString());

            xml.WriteAttributeString("RunDate", DateTime.Now.ToString());
            contexts.Do(c => this.BuildContext(xml, c));
            xml.WriteEndElement();

            Console.WriteLine(sb.ToString());
        }
Esempio n. 9
0
        public void Write(ContextCollection contexts)
        {
            StringBuilder sb  = new StringBuilder();
            StringWriter  sw  = new StringWriter(sb);
            XmlTextWriter xml = new XmlTextWriter(sw);

            xml.WriteStartElement("Contexts");
            xml.WriteAttributeString("TotalSpecs", contexts.Examples().Count().ToString());
            xml.WriteAttributeString("TotalFailed", contexts.Failures().Count().ToString());
            xml.WriteAttributeString("TotalPending", contexts.Pendings().Count().ToString());

            xml.WriteAttributeString("RunDate", DateTime.Now.ToString());
            contexts.Do(c => this.BuildContext(xml, c));
            xml.WriteEndElement();

            Console.WriteLine(sb.ToString());
        }
Esempio n. 10
0
        public void Write(ContextCollection contexts)
        {
            StringBuilder   sb         = new StringBuilder();
            StringWriter    sw         = new StringWriter(sb);
            XmlWriteWrapper xmlWrapper = new XmlWriteWrapper(sw);

            var xml = xmlWrapper.Xml;

            xml.WriteStartElement("testsuites");
            xml.WriteAttributeString("tests", contexts.Examples().Count().ToString());
            xml.WriteAttributeString("errors", "0");
            xml.WriteAttributeString("failures", contexts.Failures().Count().ToString());
            xml.WriteAttributeString("skip", contexts.Pendings().Count().ToString());

            contexts.Do(c => this.BuildContext(xmlWrapper, c));

            xml.WriteEndElement();
            xml.Flush();

            var  results        = sb.ToString();
            bool didWriteToFile = false;

            if (Options.ContainsKey("file"))
            {
                var filePath = Path.Combine(Directory.GetCurrentDirectory(), Options["file"]);

                using (var stream = new FileStream(filePath, FileMode.Create))
                    using (var writer = new StreamWriter(stream, Encoding.Unicode))
                    {
                        writer.WriteLine(results);
                        Console.WriteLine("Test results published to: {0}".With(filePath));
                    }

                didWriteToFile = true;
            }
            if (didWriteToFile && Options.ContainsKey("console"))
            {
                Console.WriteLine(results);
            }

            if (!didWriteToFile)
            {
                Console.WriteLine(results);
            }
        }
Esempio n. 11
0
        public void Write(ContextCollection contexts)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<html>");
            sb.AppendLine("<head>");
            sb.AppendLine("<style type=\"text/css\">");
            sb.AppendLine("body {font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:12px;}");
            sb.AppendLine("  span {padding: 0.5em}");
            sb.AppendLine("  ul {margin-top: 0px}");
            sb.AppendLine("  .results {background-color: #FFFFCC; border:1px solid #d8d8d8; font-weight:bold; white-space: pre-wrap; text-align: center; padding: 0.5em}");
            sb.AppendLine("  .context-parent {border:1px solid #d8d8d8; margin-bottom: 1em;}");
            sb.AppendLine("  .context-parent-title {border:1px solid #d8d8d8;font-weight:bold; padding: 0.5em;background-color:#d8d8d8}");
            sb.AppendLine("  .context-parent-body {padding: 1em 2em 1em 0;}");
            sb.AppendLine("  .context-parent-name {font-weight:bold;}");
            sb.AppendLine("  .spec-passed {font-weight:bold; color:green;}");
            sb.AppendLine("  .spec-failed {font-weight:bold; color:#FF0000;}");
            sb.AppendLine("  .spec-pending {font-weight:bold; color:#0000FF;}");
            sb.AppendLine("  .spec-exception {background-color: #FFD2CF; border:1px solid #FF828D;padding: 1em; font-size:11px; white-space: pre-wrap; padding: 0.5em}");
            sb.AppendLine("  .run-date {color:grey; font-size:x-small;}");
            sb.AppendLine("</style>");
            sb.AppendLine("</head>");
            sb.AppendLine("<body>");

            sb.AppendLine();
            sb.Append("<div class=\"results\">");
            sb.AppendFormat("<div>Assembly: {0}</div>", ((((NSpec.Domain.ClassContext)(contexts.FirstOrDefault())).type).Assembly).FullName);
            sb.AppendFormat("Specs:<span>{0}</span>", contexts.Examples().Count());
            sb.AppendFormat("Failed:<span class=\"spec-failed\">{0}</span>", contexts.Failures().Count());
            sb.AppendFormat("Pending:<span class=\"spec-pending\">{0}</span>", contexts.Pendings().Count());
            sb.AppendFormat("<div class=\"run-date\">Run Date: {0}</div>", DateTime.Now);
            sb.Append("</div>");
            sb.AppendLine();
            sb.AppendLine("<br />");

            contexts.Do(c => this.BuildParentContext(sb, c));

            sb.AppendLine("</html>");
            sb.AppendLine("</body>");

            Console.WriteLine(sb.ToString());
        }
Esempio n. 12
0
        public void Write(ContextCollection contexts)
        {
            contexts.Do(c => this.tiddlers.Add(c.Name, this.BuildTiddlerFrom(c)));

            StringBuilder menuItemsOutput = new StringBuilder();
            StringBuilder tiddlersOutput = new StringBuilder();
            foreach (var context in this.tiddlers.Keys)
            {
                menuItemsOutput.AppendFormat("[[{0}]]", context);
                menuItemsOutput.AppendLine();

                tiddlersOutput.Append(this.tiddlers[context]);
            }
            int examplesCount = contexts.Examples().Count();
            int failuresCount = contexts.Failures().Count();
            int pendingsCount = contexts.Pendings().Count();

            this.WriteTiddlyWiki(menuItemsOutput.ToString(), tiddlersOutput.ToString(),
                                 examplesCount, failuresCount, pendingsCount);
        }
Esempio n. 13
0
        public void Write(ContextCollection contexts)
        {
            contexts.Do(c => this.tiddlers.Add(c.Name, this.BuildTiddlerFrom(c)));

            StringBuilder menuItemsOutput = new StringBuilder();
            StringBuilder tiddlersOutput  = new StringBuilder();

            foreach (var context in this.tiddlers.Keys)
            {
                menuItemsOutput.AppendFormat("[[{0}]]", context);
                menuItemsOutput.AppendLine();

                tiddlersOutput.Append(this.tiddlers[context]);
            }
            int examplesCount = contexts.Examples().Count();
            int failuresCount = contexts.Failures().Count();
            int pendingsCount = contexts.Pendings().Count();

            this.WriteTiddlyWiki(menuItemsOutput.ToString(), tiddlersOutput.ToString(),
                                 examplesCount, failuresCount, pendingsCount);
        }
Esempio n. 14
0
        public void Write(ContextCollection contexts)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<html>");
            sb.AppendLine("<head>");
            sb.AppendLine("<style type=\"text/css\">");
            sb.AppendLine("  span {padding: 0.5em}");
            sb.AppendLine("  ul {margin-top: 0px}");
            sb.AppendLine("  .results {background-color: #FFFFCC; border-color: #000000; border-style: dashed; border-width: thin; font-weight:bold; white-space: pre-wrap; text-align: center; padding: 0.5em}");
            sb.AppendLine("  .context-parent {border-color: #000000; border-style: dashed; border-width: thin; margin-bottom: 1em;}");
            sb.AppendLine("  .context-parent-title {background-color: #6699FF; border-color: #000000; border-bottom-style: dashed; border-width: thin; font-weight:bold; padding: 0.5em}");
            sb.AppendLine("  .context-parent-body {padding: 1em 2em 1em 0;}");
            sb.AppendLine("  .context-parent-name {font-weight:bold;}");
            sb.AppendLine("  .spec-passed {font-weight:bold; color:green;}");
            sb.AppendLine("  .spec-failed {font-weight:bold; color:#FF0000;}");
            sb.AppendLine("  .spec-pending {font-weight:bold; color:#0000FF;}");
            sb.AppendLine("  .spec-exception {background-color: #FFD2CF; border-color: #FF828D; border-style: dashed; border-width: thin; padding: 1em; font-size:small; white-space: pre-wrap; padding: 0.5em}");
            sb.AppendLine("  .run-date {color:grey; font-size:x-small;}");
            sb.AppendLine("</style>");
            sb.AppendLine("</head>");
            sb.AppendLine("<body>");

            sb.AppendLine();
            sb.Append("<div class=\"results\">");
            sb.AppendFormat("Specs:<span>{0}</span>", contexts.Examples().Count());
            sb.AppendFormat("Failed:<span class=\"spec-failed\">{0}</span>", contexts.Failures().Count());
            sb.AppendFormat("Pending:<span class=\"spec-pending\">{0}</span>", contexts.Pendings().Count());
            sb.AppendFormat("<div class=\"run-date\">Run Date: {0}</div>", DateTime.Now);
            sb.Append("</div>");
            sb.AppendLine();
            sb.AppendLine("<br />");

            contexts.Do(c => this.BuildParentContext(sb, c));

            sb.AppendLine("</html>");
            sb.AppendLine("</body>");

            Console.WriteLine(sb.ToString());
        }
Esempio n. 15
0
        public void Write(ContextCollection contexts)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<html>");
            sb.AppendLine("<head>");
            sb.AppendLine("<style type=\"text/css\">");
            sb.AppendLine("  span {padding: 0.5em}");
            sb.AppendLine("  ul {margin-top: 0px}");
            sb.AppendLine("  .results {background-color: #FFFFCC; border-color: #000000; border-style: dashed; border-width: thin; font-weight:bold; white-space: pre-wrap; text-align: center; padding: 0.5em}");
            sb.AppendLine("  .context-parent {border-color: #000000; border-style: dashed; border-width: thin; margin-bottom: 1em;}");
            sb.AppendLine("  .context-parent-title {background-color: #6699FF; border-color: #000000; border-bottom-style: dashed; border-width: thin; font-weight:bold; padding: 0.5em}");
            sb.AppendLine("  .context-parent-body {padding: 1em 2em 1em 0;}");
            sb.AppendLine("  .context-parent-name {font-weight:bold;}");
            sb.AppendLine("  .spec-passed {font-weight:bold; color:green;}");
            sb.AppendLine("  .spec-failed {font-weight:bold; color:#FF0000;}");
            sb.AppendLine("  .spec-pending {font-weight:bold; color:#0000FF;}");
            sb.AppendLine("  .spec-exception {background-color: #FFD2CF; border-color: #FF828D; border-style: dashed; border-width: thin; padding: 1em; font-size:small; white-space: pre-wrap; padding: 0.5em}");
            sb.AppendLine("  .run-date {color:grey; font-size:x-small;}");
            sb.AppendLine("</style>");
            sb.AppendLine("</head>");
            sb.AppendLine("<body>");

            sb.AppendLine();
            sb.Append("<div class=\"results\">");
            sb.AppendFormat("Specs:<span>{0}</span>", contexts.Examples().Count());
            sb.AppendFormat("Failed:<span class=\"spec-failed\">{0}</span>", contexts.Failures().Count());
            sb.AppendFormat("Pending:<span class=\"spec-pending\">{0}</span>", contexts.Pendings().Count());
            sb.AppendFormat("<div class=\"run-date\">Run Date: {0}</div>", DateTime.Now);
            sb.Append("</div>");
            sb.AppendLine();
            sb.AppendLine("<br />");

            contexts.Do(c => this.BuildParentContext(sb, c));

            sb.AppendLine("</html>");
            sb.AppendLine("</body>");

            Console.WriteLine(sb.ToString());
        }
Esempio n. 16
0
 public void should_aggregate_pendings()
 {
     contexts.Pendings().Count().should_be(1);
 }
Esempio n. 17
0
        public string Summary(ContextCollection contexts)
        {
            var condition = new Func<ExampleBase, bool>(t => ExamplesToProcess.Count == 0 || ExamplesToProcess.Contains(GetSpecName(t)));

            var summary = "{0} Examples, {1} Failed, {2} Pending".With(
                contexts.Examples().Where(condition).Count(),
                contexts.Failures().Where(condition).Count(),
                contexts.Pendings().Where(condition).Count()
                );

            if (contexts.AnyTaggedWithFocus())
            {
                summary += "\n" + "\n" + @"NSpec found context/examples tagged with ""focus"" and only ran those.";
            }

            return summary;
        }