File tree 1 file changed +10
-4
lines changed
test/JsonApiDotNetCoreExampleTests/Acceptance/Spec
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 13
13
using Microsoft . AspNetCore . TestHost ;
14
14
using Newtonsoft . Json ;
15
15
using JsonApiDotNetCore . Models ;
16
- using System . Diagnostics ;
16
+ using JsonApiDotNetCoreExampleTests . Helpers . Extensions ;
17
17
18
18
namespace JsonApiDotNetCoreExampleTests . Acceptance . Spec
19
19
{
@@ -40,17 +40,23 @@ public async Task Can_Select_Sparse_Fieldsets()
40
40
} ;
41
41
_dbContext . TodoItems . Add ( todoItem ) ;
42
42
await _dbContext . SaveChangesAsync ( ) ;
43
+ var expectedSql = $@ "SELECT 't'.'Id', 't'.'Description'
44
+ FROM 'TodoItems' AS 't'
45
+ WHERE 't'.'Id' = { todoItem . Id } " . Normalize ( ) ;
43
46
44
47
// act
45
- var result = await _dbContext
48
+ var query = _dbContext
46
49
. TodoItems
47
50
. 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 ( ) ;
50
55
51
56
// assert
52
57
Assert . Equal ( 0 , result . Ordinal ) ;
53
58
Assert . Equal ( todoItem . Description , result . Description ) ;
59
+ Assert . Equal ( expectedSql , resultSql ) ;
54
60
}
55
61
56
62
[ Fact ]
You can’t perform that action at this time.
0 commit comments