@@ -19,7 +19,7 @@ namespace EntityFrameworkCore.Projectables.VendorTests;
1919/// </summary>
2020public class EFCoreBulkExtensionsCompatibilityTests : IDisposable
2121{
22- readonly TestDbContext _context ;
22+ private readonly TestDbContext _context ;
2323
2424 public EFCoreBulkExtensionsCompatibilityTests ( )
2525 {
@@ -59,20 +59,6 @@ public void GetDbContext_WithProjectablesEnabled_ReturnsCorrectContext()
5959 Assert . Same ( _context , dbContext ) ;
6060 }
6161
62- [ Fact ]
63- public void GetDbContext_WithProjectableProperty_DoesNotThrow ( )
64- {
65- // Arrange – entity with a [Projectable] property so that CustomQueryCompiler is
66- // exercised with actual projectable expression expansion.
67- var query = _context . Set < Order > ( ) . Where ( o => o . IsCompleted ) ;
68-
69- // Act
70- var exception = Record . Exception ( ( ) => BatchUtil . GetDbContext ( query ) ) ;
71-
72- // Assert
73- Assert . Null ( exception ) ;
74- }
75-
7662 [ Fact ]
7763 public async Task BatchDeleteAsync_WithProjectablesEnabled_DoesNotThrowTargetException ( )
7864 {
@@ -87,16 +73,11 @@ public async Task BatchDeleteAsync_WithProjectablesEnabled_DoesNotThrowTargetExc
8773 ( ) => query . BatchDeleteAsync ( TestContext . Current . CancellationToken ) ) ;
8874#pragma warning restore CS0618
8975
90- // Assert – a TargetException means the reflection-based DbContext discovery
91- // inside EFCore.BulkExtensions failed. All other exceptions (e.g. SQL syntax
92- // differences on SQLite) are acceptable because they come from actual SQL
93- // execution, not from the broken reflection chain.
94- Assert . False (
95- exception is System . Reflection . TargetException ,
96- $ "BatchDeleteAsync threw TargetException: { exception ? . Message } ") ;
97- Assert . False (
98- exception ? . Message ? . Contains ( "Non-static method requires a target" ) == true ,
99- $ "BatchDeleteAsync threw 'Non-static method requires a target': { exception ? . Message } ") ;
76+ // A TargetException means the reflection-based DbContext discovery inside
77+ // EFCore.BulkExtensions failed. Other exceptions (e.g. SQL syntax differences
78+ // on SQLite) are acceptable because they come from actual SQL execution, not
79+ // from the broken reflection chain.
80+ AssertNoTargetException ( exception , "BatchDeleteAsync" ) ;
10081 }
10182
10283 [ Fact ]
@@ -113,12 +94,12 @@ public async Task BatchUpdateAsync_WithProjectablesEnabled_DoesNotThrowTargetExc
11394 cancellationToken : TestContext . Current . CancellationToken ) ) ;
11495#pragma warning restore CS0618
11596
116- // Assert – same as above: only TargetException is a regression.
117- Assert . False (
118- exception is System . Reflection . TargetException ,
119- $ "BatchUpdateAsync threw TargetException: { exception ? . Message } ") ;
120- Assert . False (
121- exception ? . Message ? . Contains ( "Non-static method requires a target" ) == true ,
122- $ "BatchUpdateAsync threw 'Non-static method requires a target': { exception ? . Message } ") ;
97+ AssertNoTargetException ( exception , "BatchUpdateAsync" ) ;
12398 }
99+
100+ private static void AssertNoTargetException ( Exception ? exception , string operationName )
101+ => Assert . False (
102+ exception is System . Reflection . TargetException ,
103+ $ "{ operationName } threw TargetException (\" Non-static method requires a target\" ). " +
104+ $ "This indicates that CustomQueryCompiler's _queryContextFactory shadow field is missing.") ;
124105}
0 commit comments