@@ -65,15 +65,7 @@ public QueryTests()
6565 _mockDb . Setup ( m => m . Provider ) . Returns ( new AngleDatabaseProvider ( ) ) ;
6666 _mockDb . Setup ( m => m . DefaultMapper ) . Returns ( new ConventionMapper ( ) ) ;
6767
68- FlushPocoDataCache ( ) ;
69- }
70-
71- private void FlushPocoDataCache ( )
72- {
73- // This avoids having to upgrade PP just to get FlushCaches()
74- var cache = typeof ( PocoData ) . GetField ( "_pocoDatas" , BindingFlags . NonPublic | BindingFlags . Static ) . GetValue ( null ) ;
75- var flush = cache . GetType ( ) . GetMethod ( "Flush" ) ;
76- flush . Invoke ( cache , null ) ;
68+ Mappers . RevokeAll ( ) ;
7769 }
7870
7971 [ Theory , AutoData ]
@@ -112,19 +104,37 @@ public void Query_Should_Use_Plain_Value_With_No_Value_Converter(FoodEnum food)
112104 }
113105
114106 [ Theory , AutoData ]
115- public void Query_Should_Use_Mapper_For_Names ( string value )
107+ public void Query_Should_Use_Default_Mapper_For_Names ( string value )
116108 {
117109 _mockDb . Setup ( m => m . DefaultMapper ) . Returns ( new UnderscoreMapper ( ) ) ;
118110 _mockDb . Object . Query < MyClass > ( c => c . MultiWordName == value ) ;
119111 _lastSql . Should ( ) . BeEquivalentTo ( new Sql ( "WHERE <multi_word_name> = @0" , value ) ) ;
120112 }
121113
122114 [ Theory , AutoData ]
123- public void Query_Should_Use_Mapper_For_Values ( string value )
115+ public void Query_Should_Use_Default_Mapper_For_Values ( string value )
124116 {
125117 _mockDb . Setup ( m => m . DefaultMapper ) . Returns ( new SubstituteStringMapper ( ) ) ;
126118 _mockDb . Object . Query < MyClass > ( c => c . Name == value ) ;
127119 _lastSql . Should ( ) . BeEquivalentTo ( new Sql ( "WHERE <Name> = @0" , "SUBSTITUTE STRING" ) ) ;
128120 }
121+
122+ [ Theory , AutoData ]
123+ public void Query_Should_Use_Global_Mapper_For_Names ( string value )
124+ {
125+ Mappers . Register ( typeof ( MyClass ) , new UnderscoreMapper ( ) ) ;
126+
127+ _mockDb . Object . Query < MyClass > ( c => c . MultiWordName == value ) ;
128+ _lastSql . Should ( ) . BeEquivalentTo ( new Sql ( "WHERE <multi_word_name> = @0" , value ) ) ;
129+ }
130+
131+ [ Theory , AutoData ]
132+ public void Query_Should_Use_Global_Mapper_For_Values ( string value )
133+ {
134+ Mappers . Register ( typeof ( MyClass ) , new SubstituteStringMapper ( ) ) ;
135+
136+ _mockDb . Object . Query < MyClass > ( c => c . Name == value ) ;
137+ _lastSql . Should ( ) . BeEquivalentTo ( new Sql ( "WHERE <Name> = @0" , "SUBSTITUTE STRING" ) ) ;
138+ }
129139 }
130140}
0 commit comments