Beispiel #1
0
        /// <summary>
        /// Executes this Step.
        /// </summary>
        /// <returns>the resulting result</returns>
        public Result Execute()
        {
            var t = this.tags ?? Enumerable.Empty <string>();

            if (!this.IsExecutable)
            {
                return(Result.ForResultType(this.Prefix, this.IndentLevel, this.Text, t, ResultType.NotExecutable));
            }

            try
            {
                this.Action();
                return(Result.ForResultType(this.Prefix, this.IndentLevel, this.Text, t, ResultType.Passed));
            }
            catch (NotImplementedException ex)
            {
                // transform any NotImplementedException into a unit test specific "pending" exception
                var message = ex.Message == StepPendingMessage
                                     ? "Pending"
                                     : "Pending due to " + Environment.NewLine + ex;

                var pex = StoryQSettings.PendingExceptionBuilder(message, ex);
                return(Result.ForException(this.Prefix, this.IndentLevel, this.Text, t, pex, true));
            }
            catch (Exception ex)
            {
                return(Result.ForException(this.Prefix, this.IndentLevel, this.Text, t, ex, false));
            }
        }
Beispiel #2
0
        public void BuildException()
        {
            var exception = StoryQSettings.PendingExceptionBuilder("foo", null);

#if NUNIT
            //we use ignore not inconclusive for nunit (most runners turn this yellow, whereas inconclusive is red)
            Assert.IsAssignableFrom <IgnoreException>(exception);
#else
            Assert.IsTrue(exception is AssertInconclusiveException);
#endif
        }
Beispiel #3
0
        /// <summary>
        /// Formats the parameter.
        /// </summary>
        /// <param name="info">The information.</param>
        /// <param name="value">The value.</param>
        /// <returns>System.String.</returns>
        private static string FormatParameter(ParameterInfo info, object value)
        {
            var a = info.GetCustomAttribute <ParameterFormatAttribute>() ?? StoryQSettings.DefaultParameterFormatter(info);

            return(a.Format(value));
        }
Beispiel #4
0
 /// <summary>
 /// Gets the formatter.
 /// </summary>
 /// <param name="method">The method.</param>
 /// <returns>MethodFormatAttribute.</returns>
 private static MethodFormatAttribute GetFormatter(Delegate method) => method.Method.GetCustomAttribute <MethodFormatAttribute>() ?? StoryQSettings.DefaultMethodFormatSelector(method.Method);