@@ -41,15 +41,25 @@ public static void ValidateContainingOfOutputFormatter(
41
41
public static void ValidateContainingOutputFormatterOfType < TOutputFormatter > (
42
42
ObjectResult objectResult ,
43
43
Action < string , string , string > failedValidationAction )
44
+ => ValidateContainingOutputFormatterOfType ( objectResult , failedValidationAction , typeof ( TOutputFormatter ) ) ;
45
+
46
+ /// <summary>
47
+ /// Validates whether object result Formatters contains the provided type of output formatter.
48
+ /// </summary>
49
+ /// <param name="objectResult">Object result to test.</param>
50
+ /// <param name="failedValidationAction">Action to call in case of failed validation.</param>
51
+ /// <param name="outputFromatterType"></param>
52
+ public static void ValidateContainingOutputFormatterOfType (
53
+ ObjectResult objectResult ,
54
+ Action < string , string , string > failedValidationAction , Type outputFromatterType )
44
55
{
45
56
var outputFormatters = objectResult . Formatters ;
46
- var typeOfExpectedOutputFormatter = typeof ( TOutputFormatter ) ;
47
57
48
- if ( outputFormatters . All ( f => Reflection . AreDifferentTypes ( f . GetType ( ) , typeOfExpectedOutputFormatter ) ) )
58
+ if ( outputFormatters . All ( f => Reflection . AreDifferentTypes ( f . GetType ( ) , outputFromatterType ) ) )
49
59
{
50
60
failedValidationAction (
51
61
"output formatters" ,
52
- $ "to contain formatter of { typeOfExpectedOutputFormatter . Name } type",
62
+ $ "to contain formatter of { outputFromatterType . Name } type",
53
63
"such was not found" ) ;
54
64
}
55
65
}
0 commit comments