66using JsonApiDotNetCore . Graph ;
77using JsonApiDotNetCore . Hooks ;
88using JsonApiDotNetCore . Internal . Contracts ;
9+ using JsonApiDotNetCore . Internal . Generics ;
10+ using JsonApiDotNetCore . Managers . Contracts ;
911using JsonApiDotNetCore . Models ;
12+ using JsonApiDotNetCore . Query ;
13+ using JsonApiDotNetCore . Serialization ;
14+ using JsonApiDotNetCore . Serialization . Server . Builders ;
1015using JsonApiDotNetCore . Services ;
1116using Microsoft . EntityFrameworkCore ;
1217using Microsoft . Extensions . DependencyInjection ;
@@ -27,6 +32,18 @@ public ServiceDiscoveryFacadeTests()
2732 var dbResolverMock = new Mock < IDbContextResolver > ( ) ;
2833 dbResolverMock . Setup ( m => m . GetContext ( ) ) . Returns ( new Mock < DbContext > ( ) . Object ) ;
2934 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 ) ;
3047 }
3148
3249 private ServiceDiscoveryFacade _facade => new ServiceDiscoveryFacade ( _services , _resourceGraphBuilder ) ;
@@ -63,13 +80,7 @@ public void AddCurrentAssembly_Adds_Resources_To_Graph()
6380 [ Fact ]
6481 public void AddCurrentAssembly_Adds_Services_To_Container ( )
6582 {
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
7384 _facade . AddCurrentAssembly ( ) ;
7485
7586 // assert
@@ -93,26 +104,28 @@ public class TestModel : Identifiable { }
93104
94105 public class TestModelService : DefaultResourceService < TestModel >
95106 {
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 ;
98108
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 ) { }
109119 }
110120
111121 public class TestModelRepository : DefaultResourceRepository < TestModel >
112122 {
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 ) { }
116129 }
117130 }
118131}
0 commit comments