File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 88namespace AutoMapper . UnitTests
99{
1010 interface IGeneric < T > { }
11+ public class When_an_extension_methods_contraints_fail : NonValidatingSpecBase
12+ {
13+ class Source : IGeneric < int >
14+ {
15+ }
16+ class Destination
17+ {
18+ public int Count { get ; set ; }
19+ }
20+ protected override MapperConfiguration CreateConfiguration ( ) => new ( c =>
21+ {
22+ c . IncludeSourceExtensionMethods ( typeof ( GenericExtensions ) ) ;
23+ c . CreateMap < Source , Destination > ( ) ;
24+ } ) ;
25+ [ Fact ]
26+ public void It_should_fail_validation ( ) => new Action ( AssertConfigurationIsValid ) . ShouldThrow < AutoMapperConfigurationException > ( )
27+ . Errors [ 0 ] . UnmappedPropertyNames [ 0 ] . ShouldBe ( nameof ( Destination . Count ) ) ;
28+ }
1129 public class When_an_extension_method_is_for_a_base_interface : AutoMapperSpecBase
1230 {
1331 class Source : IGeneric < int >
@@ -27,7 +45,8 @@ class Destination
2745 }
2846 public static class GenericExtensions
2947 {
30- private static int GetValue ( this IGeneric < int > obj ) => 12 ;
48+ private static int GetValue ( this IGeneric < int > _ ) => 12 ;
49+ private static int Count < T > ( this IGeneric < T > _ ) where T : IDisposable => 12 ;
3150 }
3251 public class When_an_extension_method_is_for_a_base_class : AutoMapperSpecBase
3352 {
You can’t perform that action at this time.
0 commit comments