/// <summary> /// Validates the IContentNegotiator from action result containing one. /// </summary> /// <param name="actionResult">Action result with IContentNegotiator.</param> /// <param name="contentNegotiator">Expected IContentNegotiator.</param> /// <param name="failedValidationAction">Action to call in case of failed validation.</param> public static void ValidateContentNegotiator( dynamic actionResult, IContentNegotiator contentNegotiator, Action <string, string, string> failedValidationAction) { RuntimeBinderValidator.ValidateBinding(() => { var actualContentNegotiator = actionResult.ContentNegotiator as IContentNegotiator; if (Reflection.AreDifferentTypes(contentNegotiator, actualContentNegotiator)) { failedValidationAction( "IContentNegotiator", string.Format("to be {0}", contentNegotiator.GetName()), string.Format("instead received {0}", actualContentNegotiator.GetName())); } }); }
/// <summary> /// Validates the IContentNegotiator from action result containing one. /// </summary> /// <param name="actionResult">Action result with IContentNegotiator.</param> /// <param name="contentNegotiator">Expected IContentNegotiator.</param> /// <param name="failedValidationAction">Action to call in case of failed validation.</param> public static void ValidateContentNegotiator( dynamic actionResult, IContentNegotiator contentNegotiator, Action<string, string, string> failedValidationAction) { RuntimeBinderValidator.ValidateBinding(() => { var actualContentNegotiator = actionResult.ContentNegotiator as IContentNegotiator; if (Reflection.AreDifferentTypes(contentNegotiator, actualContentNegotiator)) { failedValidationAction( "IContentNegotiator", string.Format("to be {0}", contentNegotiator.GetName()), string.Format("instead received {0}", actualContentNegotiator.GetName())); } }); }