Ejemplo n.º 1
0
 /// <summary>
 /// Tests whether action result contains the same output formatter as the provided one.
 /// </summary>
 /// <param name="outputFormatter">Expected instance of <see cref="IOutputFormatter"/>.</param>
 protected void ValidateContainingOfOutputFormatter(IOutputFormatter outputFormatter)
 {
     OutputFormatterValidator.ValidateContainingOfOutputFormatter(
         this.GetObjectResult(),
         outputFormatter,
         this.ThrowNewFailedValidationException);
 }
 /// <summary>
 /// Tests whether action result contains the same output formatters as the provided ones.
 /// </summary>
 /// <param name="outputFormatters">Expected collection of <see cref="IOutputFormatter"/>.</param>
 protected void ValidateOutputFormatters(IEnumerable <IOutputFormatter> outputFormatters)
 {
     OutputFormatterValidator.ValidateOutputFormatters(
         this.GetObjectResult(),
         outputFormatters,
         this.ThrowNewFailedValidationException);
 }
 /// <summary>
 /// Tests whether action result contains type of output formatter as the provided one.
 /// </summary>
 /// <typeparam name="TOutputFormatter">Expected type of <see cref="IOutputFormatter"/>.</typeparam>
 protected void ValidateContainingOutputFormatterOfType <TOutputFormatter>()
     where TOutputFormatter : IOutputFormatter
 {
     OutputFormatterValidator.ValidateContainingOutputFormatterOfType <TOutputFormatter>(
         this.GetObjectResult(),
         this.ThrowNewFailedValidationException);
 }
        /// <summary>
        /// Tests whether the <see cref="ActionResult"/>
        /// contains the provided output formatters.
        /// </summary>
        /// <param name="baseTestBuilderWithOutputResult">
        /// Instance of <see cref="IBaseTestBuilderWithOutputResult{TOutputResultTestBuilder}"/> type.
        /// </param>
        /// <param name="outputFormatters">Collection of <see cref="IOutputFormatter"/>.</param>
        /// <returns>The same output <see cref="ActionResult"/> test builder.</returns>
        public static TOutputResultTestBuilder ContainingOutputFormatters <TOutputResultTestBuilder>(
            this IBaseTestBuilderWithOutputResult <TOutputResultTestBuilder> baseTestBuilderWithOutputResult,
            IEnumerable <IOutputFormatter> outputFormatters)
            where TOutputResultTestBuilder : IBaseTestBuilderWithActionResult
        {
            var actualBuilder = GetActualBuilder(baseTestBuilderWithOutputResult);

            ValidateObjectResult(actualBuilder);

            OutputFormatterValidator.ValidateOutputFormatters(
                actualBuilder.GetObjectResult(),
                outputFormatters,
                actualBuilder.ThrowNewFailedValidationException);

            return(actualBuilder.ResultTestBuilder);
        }
        /// <summary>
        /// Tests whether the <see cref="ActionResult"/>
        /// contains <see cref="IOutputFormatter"/> of the provided type.
        /// </summary>
        /// <param name="baseTestBuilderWithOutputResult">
        /// Instance of <see cref="IBaseTestBuilderWithOutputResult{TOutputResultTestBuilder}"/> type.
        /// </param>
        /// <returns>The same output <see cref="ActionResult"/> test builder.</returns>
        public static TOutputResultTestBuilder ContainingOutputFormatterOfType <
            TOutputResultTestBuilder, TOutputFormatter>(
            this IBaseTestBuilderWithOutputResult <TOutputResultTestBuilder> baseTestBuilderWithOutputResult)
            where TOutputResultTestBuilder : IBaseTestBuilderWithActionResult
            where TOutputFormatter : IOutputFormatter
        {
            var actualBuilder = GetActualBuilder(baseTestBuilderWithOutputResult);

            ValidateObjectResult(actualBuilder);

            OutputFormatterValidator.ValidateContainingOutputFormatterOfType <TOutputFormatter>(
                actualBuilder.GetObjectResult(),
                actualBuilder.ThrowNewFailedValidationException);

            return(actualBuilder.ResultTestBuilder);
        }