Beispiel #1
0
        /// <summary>
        /// Check that the code does not throw an exception.
        /// </summary>
        /// <returns>
        /// A check link.
        /// </returns>
        /// <exception cref="FluentCheckException">
        /// The code raised an exception.
        /// </exception>
        public ICheckLink <ILambdaCheck> DoesNotThrow()
        {
            var check = new FluentCodeCheck <RunTrace>(this.runTrace);

            check.DoesNotThrow();
            return(new CheckLink <ILambdaCheck>(this));
        }
Beispiel #2
0
        /// <summary>
        /// Checks that the code did throw an exception of any type.
        /// </summary>
        /// <returns>
        /// A check link.
        /// </returns>
        /// <exception cref="FluentCheckException">
        /// The code did not raised an exception of any type.
        /// </exception>
        public ILambdaExceptionCheck <ILambdaCheck> ThrowsAny()
        {
            var check = new FluentCodeCheck <RunTrace>(this.runTrace);

            check.ThrowsAny();
            return(new LambdaExceptionCheck <ILambdaCheck>(this.runTrace.RaisedException));
        }
Beispiel #3
0
        /// <summary>
        /// Checks that the execution time is below a specified threshold.
        /// </summary>
        /// <param name="threshold">
        /// The threshold.
        /// </param>
        /// <param name="timeUnit">
        /// The time unit of the given threshold.
        /// </param>
        /// <returns>
        /// A check link.
        /// </returns>
        /// <exception cref="FluentCheckException">
        /// Execution was strictly above limit.
        /// </exception>
        public ICheckLink <ILambdaCheck> LastsLessThan(double threshold, TimeUnit timeUnit)
        {
            var check = new FluentCodeCheck <RunTrace>(this.runTrace);

            check.LastsLessThan(threshold, timeUnit);
            return(new CheckLink <ILambdaCheck>(this));
        }
Beispiel #4
0
 /// <summary>
 /// Returns a <see cref="ICheck{T}" /> instance that will provide check methods to be executed on a given async function (returning Task{TResult}).
 /// </summary>
 /// <typeparam name="TResult">The type of the result for this asynchronous function.</typeparam>
 /// <param name="awaitableFunction">The asynchronous function to be tested.</param>
 /// <returns>
 /// A <see cref="ICheck{RunTrace}" /> instance to use in order to assert things on the given value.
 /// </returns>
 /// <remarks>
 /// Every method of the returned <see cref="ICheck{T}" /> instance will throw a <see cref="FluentCheckException" /> when failing.
 /// </remarks>
 public static ICodeCheck <RunTraceResult <TResult> > ThatAsyncCode <TResult>(Func <Task <TResult> > awaitableFunction)
 {
     return(new FluentCodeCheck <RunTraceResult <TResult> >(FluentCodeCheck <RunTraceResult <Task <TResult> > > .GetAsyncTrace(awaitableFunction)));
 }
Beispiel #5
0
 /// <summary>
 /// Returns a <see cref="ICheck{T}" /> instance that will provide check methods to be executed on a given async code (returning Task).
 /// </summary>
 /// <param name="awaitableMethod">The async code to be tested.</param>
 /// <returns>
 /// A <see cref="ICheck{RunTrace}" /> instance to use in order to assert things on the given value.
 /// </returns>
 /// <remarks>
 /// Every method of the returned <see cref="ICheck{T}" /> instance will throw a <see cref="FluentCheckException" /> when failing.
 /// </remarks>
 public static ICodeCheck <RunTrace> ThatAsyncCode(Func <Task> awaitableMethod)
 {
     return(new FluentCodeCheck <RunTrace>(FluentCodeCheck <RunTraceResult <Func <Task> > > .GetAsyncTrace(awaitableMethod)));
 }
Beispiel #6
0
 /// <summary>
 /// Returns a <see cref="ICheck{T}" /> instance that will provide check methods to be executed on a lambda.
 /// </summary>
 /// <typeparam name="TU">Result type of the function.</typeparam>
 /// <param name="value">The code to be tested.</param>
 /// <returns>
 /// A <see cref="ICheck{RunTrace}" /> instance to use in order to assert things on the lambda.
 /// </returns>
 /// <remarks>
 /// Every method of the returned <see cref="ICheck{T}" /> instance will throw a <see cref="FluentCheckException" /> when failing.
 /// </remarks>
 public static ICodeCheck <RunTraceResult <TU> > ThatCode <TU>(Func <TU> value)
 {
     return(new FluentCodeCheck <RunTraceResult <TU> >(FluentCodeCheck <RunTraceResult <TU> > .GetTrace(value)));
 }
Beispiel #7
0
 /// <summary>
 /// Returns a <see cref="ICheck{T}" /> instance that will provide check methods to be executed on a given value.
 /// </summary>
 /// <param name="value">The code to be tested.</param>
 /// <returns>
 /// A <see cref="ICheck{RunTrace}" /> instance to use in order to assert things on the given value.
 /// </returns>
 /// <remarks>
 /// Every method of the returned <see cref="ICheck{T}" /> instance will throw a <see cref="FluentCheckException" /> when failing.
 /// </remarks>
 public static ICodeCheck <RunTrace> ThatCode(Action value)
 {
     return(new FluentCodeCheck <RunTrace>(FluentCodeCheck <RunTraceResult <Action> > .GetTrace(value)));
 }