Exemplo n.º 1
0
        public void Write(Example example, int level)
        {
            var result = example.Failed()
                ? new TestResultDTO { Outcome = TestOutcome.Failed, StackTrace = GetStackTrace(example.Exception), Message = example.Exception.Message }
                : new TestResultDTO { Outcome = example.Pending ? TestOutcome.Skipped : TestOutcome.Passed };
            result.TestName = example.FullName();
            result.Source = this.Source;

            this.observer.Receive(result);
        }
Exemplo n.º 2
0
        public void should_concatenate_its_contexts_name_into_a_full_name()
        {
            var context = new Context("context name");

            var example = new Example("example name");

            context.AddExample(example);

            example.FullName().should_be("context name. example name.");
        }
Exemplo n.º 3
0
        public string WriteFailure(Example example)
        {
            var failure = Environment.NewLine + example.FullName().Replace("_", " ") + Environment.NewLine;

            failure += example.Exception.CleanMessage() +
                Environment.NewLine + example.Exception.GetOrFallback( e=> e.StackTrace,"").Split('\n')
                    .Where(l => !new[] { "NSpec.Domain","NSpec.AssertionExtensions","NUnit.Framework" }.Any(l.Contains))
                    .Flatten(Environment.NewLine).TrimEnd() + Environment.NewLine;

            return failure;
        }
Exemplo n.º 4
0
        public string WriteFailure(Example example)
        {
            var failure = Environment.NewLine + example.FullName().Replace("_", " ") + Environment.NewLine;

            failure += example.Exception.CleanMessage() +
                       Environment.NewLine + example.Exception.GetOrFallback(e => e.StackTrace, "").Split('\n')
                       .Where(l => !new[] { "NSpec.Domain", "NSpec.AssertionExtensions", "NUnit.Framework" }.Any(l.Contains))
                       .Flatten(Environment.NewLine).TrimEnd() + Environment.NewLine;

            return(failure);
        }
Exemplo n.º 5
0
        public string WriteFailure(Example example)
        {
            var failure = Environment.NewLine + example.FullName().Replace("_", " ") + Environment.NewLine;

            failure += example.Exception.CleanMessage() + Environment.NewLine;

            var stackTrace =
                example.Exception
                .GetOrFallback(e => e.StackTrace, "").Split('\n')
                .Where(l => !internalNameSpaces.Any(l.Contains));

            var flattenedStackTrace = stackTrace.Flatten(Environment.NewLine).TrimEnd() + Environment.NewLine;

            failure += flattenedStackTrace;

            return(failure);
        }
Exemplo n.º 6
0
        public string WriteFailure(Example example)
        {
            var failure = Environment.NewLine + example.FullName().Replace("_", " ") + Environment.NewLine;

            failure += example.Exception.CleanMessage() + Environment.NewLine;

            var stackTrace =
                example.Exception
                       .GetOrFallback(e => e.StackTrace, "").Split('\n')
                       .Where(l => !internalNameSpaces.Any(l.Contains));

            var flattenedStackTrace = stackTrace.Flatten(Environment.NewLine).TrimEnd() + Environment.NewLine;

            failure += flattenedStackTrace;

            return failure;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:NSpecAdapterForxUnit.ExampleCommand"/> to a specific <see cref="T:NSpec.Domain.Example"/>.
        /// </summary>
        /// <param name="method">The method that contains the <paramref name="example"/>.</param>
        /// <param name="example">The example to run.</param>
        /// <param name="instance">The instance to run the example.</param>
        /// <exception cref="T:System.ArgumentNullException">One of the arguments is <see langword="null"/>. </exception>
        public ExampleCommand(IMethodInfo method, Example example, nspec instance)
            : base(method, example.FullName(), 0)
        {
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }

            if (example == null)
            {
                throw new ArgumentNullException("example");
            }

            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            this.Method = method;
            this.Example = example;
            this.Instance = instance;
        }