6
6
using JsonApiDotNetCore . Graph ;
7
7
using JsonApiDotNetCore . Hooks ;
8
8
using JsonApiDotNetCore . Internal . Contracts ;
9
+ using JsonApiDotNetCore . Internal . Generics ;
10
+ using JsonApiDotNetCore . Managers . Contracts ;
9
11
using JsonApiDotNetCore . Models ;
12
+ using JsonApiDotNetCore . Query ;
13
+ using JsonApiDotNetCore . Serialization ;
14
+ using JsonApiDotNetCore . Serialization . Server . Builders ;
10
15
using JsonApiDotNetCore . Services ;
11
16
using Microsoft . EntityFrameworkCore ;
12
17
using Microsoft . Extensions . DependencyInjection ;
@@ -27,6 +32,18 @@ public ServiceDiscoveryFacadeTests()
27
32
var dbResolverMock = new Mock < IDbContextResolver > ( ) ;
28
33
dbResolverMock . Setup ( m => m . GetContext ( ) ) . Returns ( new Mock < DbContext > ( ) . Object ) ;
29
34
TestModelRepository . _dbContextResolver = dbResolverMock . Object ;
35
+ _services . AddSingleton < IJsonApiOptions > ( new JsonApiOptions ( ) ) ;
36
+ _services . AddScoped ( ( _ ) => new Mock < ILinkBuilder > ( ) . Object ) ;
37
+ _services . AddScoped ( ( _ ) => new Mock < ICurrentRequest > ( ) . Object ) ;
38
+ _services . AddScoped ( ( _ ) => new Mock < IPageService > ( ) . Object ) ;
39
+ _services . AddScoped ( ( _ ) => new Mock < ISparseFieldsService > ( ) . Object ) ;
40
+ _services . AddScoped ( ( _ ) => new Mock < IFilterService > ( ) . Object ) ;
41
+ _services . AddScoped ( ( _ ) => new Mock < IIncludeService > ( ) . Object ) ;
42
+ _services . AddScoped ( ( _ ) => new Mock < ISortService > ( ) . Object ) ;
43
+ _services . AddScoped ( ( _ ) => new Mock < ITargetedFields > ( ) . Object ) ;
44
+ _services . AddScoped ( ( _ ) => new Mock < IResourceGraph > ( ) . Object ) ;
45
+ _services . AddScoped ( ( _ ) => new Mock < IGenericServiceFactory > ( ) . Object ) ;
46
+ _services . AddScoped ( ( _ ) => new Mock < IResourceContextProvider > ( ) . Object ) ;
30
47
}
31
48
32
49
private ServiceDiscoveryFacade _facade => new ServiceDiscoveryFacade ( _services , _resourceGraphBuilder ) ;
@@ -63,13 +80,7 @@ public void AddCurrentAssembly_Adds_Resources_To_Graph()
63
80
[ Fact ]
64
81
public void AddCurrentAssembly_Adds_Services_To_Container ( )
65
82
{
66
- // arrange, act
67
- _services . AddSingleton < IJsonApiOptions > ( new JsonApiOptions ( ) ) ;
68
-
69
- _services . AddScoped ( ( _ ) => new Mock < ILinkBuilder > ( ) . Object ) ;
70
- _services . AddScoped ( ( _ ) => new Mock < IRequestContext > ( ) . Object ) ;
71
- _services . AddScoped ( ( _ ) => new Mock < IPageQueryService > ( ) . Object ) ;
72
- _services . AddScoped ( ( _ ) => new Mock < IResourceGraph > ( ) . Object ) ;
83
+ // arrange, act
73
84
_facade . AddCurrentAssembly ( ) ;
74
85
75
86
// assert
@@ -93,26 +104,28 @@ public class TestModel : Identifiable { }
93
104
94
105
public class TestModelService : DefaultResourceService < TestModel >
95
106
{
96
- private static IResourceRepository < TestModel > _repo = new Mock < IResourceRepository < TestModel > > ( ) . Object ;
97
- private static IJsonApiContext _jsonApiContext = new Mock < IJsonApiContext > ( ) . Object ;
107
+ private static IResourceRepository < TestModel > _repo = new Mock < IResourceRepository < TestModel > > ( ) . Object ;
98
108
99
- public TestModelService (
100
- IResourceRepository < TestModel > repository ,
101
- IJsonApiOptions options ,
102
- IRequestContext currentRequest ,
103
- IPageQueryService pageService ,
104
- IResourceGraph resourceGraph ,
105
- ILoggerFactory loggerFactory = null ,
106
- IResourceHookExecutor hookExecutor = null ) : base ( repository , options , currentRequest , pageService , resourceGraph , loggerFactory , hookExecutor )
107
- {
108
- }
109
+ public TestModelService ( ISortService sortService ,
110
+ IFilterService filterService ,
111
+ IJsonApiOptions options ,
112
+ IIncludeService includeService ,
113
+ ISparseFieldsService sparseFieldsService ,
114
+ IPageService pageManager ,
115
+ IResourceContextProvider provider ,
116
+ IResourceHookExecutor hookExecutor = null ,
117
+ ILoggerFactory loggerFactory = null )
118
+ : base ( sortService , filterService , _repo , options , includeService , sparseFieldsService , pageManager , provider , hookExecutor , loggerFactory ) { }
109
119
}
110
120
111
121
public class TestModelRepository : DefaultResourceRepository < TestModel >
112
122
{
113
- internal static IDbContextResolver _dbContextResolver ;
114
- private static IJsonApiContext _jsonApiContext = new Mock < IJsonApiContext > ( ) . Object ;
115
- public TestModelRepository ( ) : base ( _jsonApiContext , _dbContextResolver ) { }
123
+ internal static IDbContextResolver _dbContextResolver ;
124
+
125
+ public TestModelRepository ( ITargetedFields targetedFields ,
126
+ IResourceGraph resourceGraph ,
127
+ IGenericServiceFactory genericServiceFactory )
128
+ : base ( targetedFields , _dbContextResolver , resourceGraph , genericServiceFactory ) { }
116
129
}
117
130
}
118
131
}
0 commit comments