File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- global using GraphQL . EntityFramework . Testing ;
1+ global using GraphQL . EntityFramework ;
2+ global using GraphQL . EntityFramework . Testing ;
23global using GraphQL . Types ;
34global using GraphQL . Utilities ;
4- global using Microsoft . AspNetCore . Hosting ;
55global using Microsoft . AspNetCore . TestHost ;
66global using Microsoft . Extensions . DependencyInjection ;
77global using Microsoft . Extensions . Logging ;
Original file line number Diff line number Diff line change 1- using System . Net ;
1+ using System . Net ;
2+ using Microsoft . AspNetCore . Mvc . Testing ;
23using Newtonsoft . Json ;
34// ReSharper disable PrivateFieldCanBeConvertedToLocalVariable
4- #pragma warning disable ASPDEPR008
5- #pragma warning disable ASPDEPR004
65
76#region GraphQlControllerTests
87
@@ -14,9 +13,9 @@ public class GraphQlControllerTests
1413
1514 static GraphQlControllerTests ( )
1615 {
17- var server = GetTestServer ( ) ;
18- client = server . CreateClient ( ) ;
19- webSocket = server . CreateWebSocketClient ( ) ;
16+ var factory = new WebApplicationFactory < Program > ( ) ;
17+ client = factory . CreateClient ( ) ;
18+ webSocket = factory . Server . CreateWebSocketClient ( ) ;
2019 webSocket . ConfigureRequest =
2120 request =>
2221 {
@@ -240,13 +239,6 @@ public async Task Complex_query_result()
240239 response . EnsureSuccessStatusCode ( ) ;
241240 await Verify ( result ) ;
242241 }
243-
244- static TestServer GetTestServer ( )
245- {
246- var builder = new WebHostBuilder ( ) ;
247- builder . UseStartup < Startup > ( ) ;
248- return new ( builder ) ;
249- }
250242}
251243
252- #endregion
244+ #endregion
Original file line number Diff line number Diff line change 1- using GraphQL ;
1+ using GraphQL ;
2+ using GraphQL . Types ;
23
34public class SchemaPrint
45{
@@ -7,11 +8,27 @@ public async Task Print()
78 {
89 var services = new ServiceCollection ( ) ;
910 services . AddSingleton < ILoggerFactory > ( _ => NullLoggerFactory . Instance ) ;
10- new Startup ( ) . ConfigureServices ( services ) ;
11+
12+ EfGraphQLConventions . RegisterInContainer < SampleDbContext > (
13+ services ,
14+ model : SampleDbContext . StaticModel ) ;
15+
16+ foreach ( var type in typeof ( Program ) . Assembly
17+ . GetTypes ( )
18+ . Where ( _ => ! _ . IsAbstract &&
19+ ( _ . IsAssignableTo ( typeof ( IObjectGraphType ) ) ||
20+ _ . IsAssignableTo ( typeof ( IInputObjectGraphType ) ) ) ) )
21+ {
22+ services . AddSingleton ( type ) ;
23+ }
24+
25+ services . AddSingleton < IDocumentExecuter , EfDocumentExecuter > ( ) ;
26+ services . AddSingleton < ISchema , Schema > ( ) ;
27+ services . AddGraphQL ( null ) ;
1128
1229 await using var provider = services . BuildServiceProvider ( ) ;
1330 var schema = provider . GetRequiredService < ISchema > ( ) ;
1431 var print = schema . Print ( ) ;
1532 await Verify ( print ) ;
1633 }
17- }
34+ }
You can’t perform that action at this time.
0 commit comments