1
1
using System ;
2
+ using System . Collections . Generic ;
2
3
using System . Data ;
3
4
using System . Linq ;
4
5
using System . Threading . Tasks ;
@@ -393,10 +394,11 @@ value set('one', 'two', 'four', 'eight') null
393
394
394
395
395
396
#if ! BASELINE
396
- [ Fact ]
397
- public void InsertReadOnlyMemory ( )
397
+ [ Theory ]
398
+ [ MemberData ( nameof ( GetBlobs ) ) ]
399
+ public void InsertBlob ( object data , bool prepare )
398
400
{
399
- using ( var connection = new MySqlConnection ( AppConfig . ConnectionString ) )
401
+ using ( var connection = new MySqlConnection ( AppConfig . ConnectionString + ";IgnorePrepare=false" ) )
400
402
{
401
403
connection . Open ( ) ;
402
404
connection . Execute ( @"drop table if exists insert_mysql_blob;
@@ -407,32 +409,26 @@ value mediumblob null
407
409
408
410
using ( var cmd = new MySqlCommand ( "insert into insert_mysql_blob(value) values(@data);" , connection ) )
409
411
{
410
- cmd . Parameters . AddWithValue ( "@data" , new ReadOnlyMemory < byte > ( new byte [ ] { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } , 1 , 6 ) ) ;
412
+ cmd . Parameters . AddWithValue ( "@data" , data ) ;
413
+ if ( prepare )
414
+ cmd . Prepare ( ) ;
411
415
cmd . ExecuteNonQuery ( ) ;
412
416
}
413
417
Assert . Equal ( new byte [ ] { 1 , 2 , 3 , 4 , 5 , 6 } , connection . Query < byte [ ] > ( @"select value from insert_mysql_blob;" ) . Single ( ) ) ;
414
418
}
415
419
}
416
420
417
- [ Fact ]
418
- public void InsertReadOnlyMemoryPrepared ( )
421
+ public static IEnumerable < object [ ] > GetBlobs ( )
419
422
{
420
- using ( var connection = new MySqlConnection ( AppConfig . ConnectionString + ";IgnorePrepare=false" ) )
423
+ foreach ( var blob in new object [ ]
421
424
{
422
- connection . Open ( ) ;
423
- connection . Execute ( @"drop table if exists insert_mysql_blob;
424
- create table insert_mysql_blob(
425
- rowid integer not null primary key auto_increment,
426
- value mediumblob null
427
- );" ) ;
428
-
429
- using ( var cmd = new MySqlCommand ( "insert into insert_mysql_blob(value) values(@data);" , connection ) )
430
- {
431
- cmd . Parameters . AddWithValue ( "@data" , new ReadOnlyMemory < byte > ( new byte [ ] { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } , 1 , 6 ) ) ;
432
- cmd . Prepare ( ) ;
433
- cmd . ExecuteNonQuery ( ) ;
434
- }
435
- Assert . Equal ( new byte [ ] { 1 , 2 , 3 , 4 , 5 , 6 } , connection . Query < byte [ ] > ( @"select value from insert_mysql_blob;" ) . Single ( ) ) ;
425
+ new byte [ ] { 1 , 2 , 3 , 4 , 5 , 6 } ,
426
+ new ReadOnlyMemory < byte > ( new byte [ ] { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } , 1 , 6 ) ,
427
+ new Memory < byte > ( new byte [ ] { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } , 1 , 6 ) ,
428
+ } )
429
+ {
430
+ yield return new [ ] { blob , false } ;
431
+ yield return new [ ] { blob , true } ;
436
432
}
437
433
}
438
434
#endif
0 commit comments