Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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)));
 }
Exemplo n.º 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)));
 }
Exemplo n.º 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)));
 }
Exemplo n.º 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)));
 }