@@ -141,4 +141,44 @@ public async Task Main()
141
141
Assert . Equal ( new int [ ] { 1 , 3 , 2 } , neighbors . Select ( v => v . Entity . Id ) . ToArray ( ) ) ;
142
142
Assert . Equal ( new double [ ] { 0 , 1 , Math . Sqrt ( 3 ) } , neighbors . Select ( v => v . Distance ) . ToArray ( ) ) ;
143
143
}
144
+
145
+ [ Theory ]
146
+ [ InlineData ( typeof ( Vector ) , null , "vector" ) ]
147
+ [ InlineData ( typeof ( Vector ) , 3 , "vector(3)" ) ]
148
+ [ InlineData ( typeof ( HalfVector ) , null , "halfvec" ) ]
149
+ [ InlineData ( typeof ( HalfVector ) , 3 , "halfvec(3)" ) ]
150
+ [ InlineData ( typeof ( BitArray ) , null , "bit varying" ) ]
151
+ [ InlineData ( typeof ( BitArray ) , 3 , "bit varying(3)" ) ]
152
+ [ InlineData ( typeof ( SparseVector ) , null , "sparsevec" ) ]
153
+ [ InlineData ( typeof ( SparseVector ) , 3 , "sparsevec(3)" ) ]
154
+ public void ByStoreType ( Type type , int ? size , string expectedStoreType )
155
+ {
156
+ using var ctx = new ItemContext ( ) ;
157
+ var typeMappingSource = ctx . GetService < IRelationalTypeMappingSource > ( ) ;
158
+
159
+ var typeMapping = typeMappingSource . FindMapping ( type , storeTypeName : null , size : size ) ! ;
160
+ Assert . Equal ( expectedStoreType , typeMapping . StoreType ) ;
161
+ Assert . Same ( type , typeMapping . ClrType ) ;
162
+ Assert . Equal ( size , typeMapping . Size ) ;
163
+ }
164
+
165
+ [ Theory ]
166
+ [ InlineData ( "vector" , typeof ( Vector ) , null ) ]
167
+ [ InlineData ( "vector(3)" , typeof ( Vector ) , 3 ) ]
168
+ [ InlineData ( "halfvec" , typeof ( HalfVector ) , null ) ]
169
+ [ InlineData ( "halfvec(3)" , typeof ( HalfVector ) , 3 ) ]
170
+ [ InlineData ( "bit varying" , typeof ( BitArray ) , null ) ]
171
+ [ InlineData ( "bit(3)" , typeof ( BitArray ) , 3 ) ]
172
+ [ InlineData ( "sparsevec" , typeof ( SparseVector ) , null ) ]
173
+ [ InlineData ( "sparsevec(3)" , typeof ( SparseVector ) , 3 ) ]
174
+ public void ByClrType ( string storeType , Type expectedType , int ? expectedSize )
175
+ {
176
+ using var ctx = new ItemContext ( ) ;
177
+ var typeMappingSource = ctx . GetService < IRelationalTypeMappingSource > ( ) ;
178
+
179
+ var typeMapping = typeMappingSource . FindMapping ( storeType ) ! ;
180
+ Assert . Equal ( storeType , typeMapping . StoreType ) ;
181
+ Assert . Same ( expectedType , typeMapping . ClrType ) ;
182
+ Assert . Equal ( expectedSize , typeMapping . Size ) ;
183
+ }
144
184
}
0 commit comments