File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
test/JsonApiDotNetCoreExampleTests/Acceptance/Spec Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 1313using Microsoft . AspNetCore . TestHost ;
1414using Newtonsoft . Json ;
1515using JsonApiDotNetCore . Models ;
16- using System . Diagnostics ;
16+ using JsonApiDotNetCoreExampleTests . Helpers . Extensions ;
1717
1818namespace JsonApiDotNetCoreExampleTests . Acceptance . Spec
1919{
@@ -40,17 +40,23 @@ public async Task Can_Select_Sparse_Fieldsets()
4040 } ;
4141 _dbContext . TodoItems . Add ( todoItem ) ;
4242 await _dbContext . SaveChangesAsync ( ) ;
43+ var expectedSql = $@ "SELECT 't'.'Id', 't'.'Description'
44+ FROM 'TodoItems' AS 't'
45+ WHERE 't'.'Id' = { todoItem . Id } " . Normalize ( ) ;
4346
4447 // act
45- var result = await _dbContext
48+ var query = _dbContext
4649 . TodoItems
4750 . Where ( t=> t . Id == todoItem . Id )
48- . Select ( fields )
49- . FirstAsync ( ) ;
51+ . Select ( fields ) ;
52+
53+ var resultSql = query . ToSql ( ) . Normalize ( ) ;
54+ var result = await query . FirstAsync ( ) ;
5055
5156 // assert
5257 Assert . Equal ( 0 , result . Ordinal ) ;
5358 Assert . Equal ( todoItem . Description , result . Description ) ;
59+ Assert . Equal ( expectedSql , resultSql ) ;
5460 }
5561
5662 [ Fact ]
You can’t perform that action at this time.
0 commit comments