public static class AutoMapperTestHelper { public static void ShouldFormatValueAs( this IValueFormatter formatter, TInput input, string expectedOutput) { ResolutionContext rc = new ResolutionContext(null, input, typeof(TInput), typeof(string)); string actualOutput = formatter.FormatValue(rc); if (!actualOutput.Equals(expectedOutput)) { throw new AutoMapperOutputAssertionException(String.Format( "Expected IValueFormatter output: {0}. Actual output: {1}", expectedOutput, actualOutput)); } } } public class AutoMapperOutputAssertionException : Exception { public AutoMapperOutputAssertionException(string message) : base(message) { } }