@@ -475,115 +475,35 @@ public async Task BulkUpsertImporter_ThrowsOnNonexistentTable()
475475 await Assert . ThrowsAsync < YdbException > ( async ( ) => { await importer . FlushAsync ( ) ; } ) ;
476476 }
477477
478- [ Fact ]
479- public async Task EnableImplicitSession_WhenTrue_ButInsideTransaction_UsesPooledSession ( )
480- {
481- var cs = ConnectionString + ";EnableImplicitSession=true" ;
482-
483- await using var conn = new YdbConnection ( cs ) ;
484- await conn . OpenAsync ( ) ;
485-
486- using var tx = conn . BeginTransaction ( ) ;
487- var cmd = conn . CreateCommand ( ) ;
488- cmd . Transaction = tx ;
489- cmd . CommandText = "SELECT 1" ;
490- var result = Convert . ToInt64 ( await cmd . ExecuteScalarAsync ( ) ) ;
491- Assert . Equal ( 1L , result ) ;
492-
493- Assert . IsNotType < ImplicitSession > ( conn . Session ) ;
494- }
495-
496- [ Fact ]
497- public async Task EnableImplicitSession_WhenFalse_AlwaysUsesPooledSession ( )
498- {
499- var cs = ConnectionString + ";EnableImplicitSession=false" ;
500-
501- await using var conn = new YdbConnection ( cs ) ;
502- await conn . OpenAsync ( ) ;
503-
504- var cmd = conn . CreateCommand ( ) ;
505- cmd . CommandText = "SELECT CAST(1 AS Int64)" ;
506- var result = ( long ) ( await cmd . ExecuteScalarAsync ( ) ) ! ;
507- Assert . Equal ( 1L , result ) ;
508-
509- Assert . IsNotType < ImplicitSession > ( conn . Session ) ;
510- }
511-
512- [ Fact ]
513- public async Task EnableImplicitSession_DifferentConnectionStrings_HaveDifferentImplicitPools ( )
514- {
515- var cs1 = ConnectionString + ";EnableImplicitSession=true;MinSessionPool=0;DisableDiscovery=false" ;
516- var cs2 = ConnectionString + ";EnableImplicitSession=true;MinSessionPool=1;DisableDiscovery=false" ;
517-
518- await using var conn1 = new YdbConnection ( cs1 ) ;
519- await conn1 . OpenAsync ( ) ;
520- var s1 = conn1 . Session ;
521-
522- await using var conn2 = new YdbConnection ( cs2 ) ;
523- await conn2 . OpenAsync ( ) ;
524- var s2 = conn2 . Session ;
525-
526- Assert . NotEqual ( s1 , s2 ) ;
527- }
528-
529- [ Fact ]
530- public async Task EnableImplicitSession_TwoSequentialCommands_ReusesSameSession ( )
531- {
532- var cs = ConnectionString + ";EnableImplicitSession=true" ;
533- await using var conn = new YdbConnection ( cs ) ;
534- await conn . OpenAsync ( ) ;
535-
536- var cmd1 = conn . CreateCommand ( ) ;
537- cmd1 . CommandText = "SELECT 1;" ;
538- await cmd1 . ExecuteScalarAsync ( ) ;
539-
540- var s1 = conn . Session ;
541-
542- var cmd2 = conn . CreateCommand ( ) ;
543- cmd2 . CommandText = "SELECT 2;" ;
544- await cmd2 . ExecuteScalarAsync ( ) ;
545-
546- var s2 = conn . Session ;
547-
548- Assert . Equal ( s1 , s2 ) ;
549- }
550-
551478 [ Fact ]
552479 public async Task ClearPool_FireAndForget_DoesNotBlock_And_PoolsRecreate ( )
553480 {
554- var csBase =
555- ConnectionString +
556- ";UseTls=false" +
557- ";DisableDiscovery=true" +
558- ";CreateSessionTimeout=3" +
559- ";ConnectTimeout=3" +
560- ";KeepAlivePingDelay=0;KeepAlivePingTimeout=0" ;
561-
562- var csPooled = csBase ;
563- var csImplicit = csBase + ";EnableImplicitSession=true" ;
481+ var csPooled = ConnectionString +
482+ "UseTls=false;DisableDiscovery=true;" +
483+ "CreateSessionTimeout=3;ConnectTimeout=3;" +
484+ "KeepAlivePingDelay=0;KeepAlivePingTimeout=0" ;
485+ var csImplicit = csPooled + ";EnableImplicitSession=true" ;
564486
565487 await using ( var warmPooled = new YdbConnection ( csPooled ) )
566488 {
567489 await warmPooled . OpenAsync ( ) ;
568- using var cmd = warmPooled . CreateCommand ( ) ;
490+ await using var cmd = warmPooled . CreateCommand ( ) ;
569491 cmd . CommandText = "SELECT 1" ;
570492 Assert . Equal ( 1L , Convert . ToInt64 ( await cmd . ExecuteScalarAsync ( ) ) ) ;
571493 }
572494
573495 await using ( var warmImplicit = new YdbConnection ( csImplicit ) )
574496 {
575497 await warmImplicit . OpenAsync ( ) ;
576- using var cmd = warmImplicit . CreateCommand ( ) ;
498+ await using var cmd = warmImplicit . CreateCommand ( ) ;
577499 cmd . CommandText = "SELECT 1" ;
578500 Assert . Equal ( 1L , Convert . ToInt64 ( await cmd . ExecuteScalarAsync ( ) ) ) ;
579501 }
580502
581503 var clearPooledTask = YdbConnection . ClearPool ( new YdbConnection ( csPooled ) ) ;
582504 var clearImplicitTask = YdbConnection . ClearPool ( new YdbConnection ( csImplicit ) ) ;
583505
584- var done = await Task . WhenAny ( Task . WhenAll ( clearPooledTask , clearImplicitTask ) ,
585- Task . Delay ( TimeSpan . FromSeconds ( 2 ) ) ) ;
586- Assert . True ( done != Task . Delay ( TimeSpan . FromSeconds ( 2 ) ) , "ClearPool() must not block." ) ;
506+ await Task . WhenAll ( clearPooledTask , clearImplicitTask ) ;
587507
588508 await using ( var checkPooled = new YdbConnection ( csPooled ) )
589509 {
@@ -601,15 +521,4 @@ public async Task ClearPool_FireAndForget_DoesNotBlock_And_PoolsRecreate()
601521 Assert . Equal ( 1L , Convert . ToInt64 ( await cmd . ExecuteScalarAsync ( ) ) ) ;
602522 }
603523 }
604-
605- [ Fact ]
606- public async Task EnableImplicitSession_WithDisableDiscovery_Works ( )
607- {
608- var cs = ConnectionString + ";EnableImplicitSession=true;DisableDiscovery=true" ;
609- await using var conn = new YdbConnection ( cs ) ;
610- await conn . OpenAsync ( ) ;
611- using var cmd = conn . CreateCommand ( ) ;
612- cmd . CommandText = "SELECT 1" ;
613- Assert . Equal ( 1L , Convert . ToInt64 ( await cmd . ExecuteScalarAsync ( ) ) ) ;
614- }
615524}
0 commit comments