diff --git a/benchmarks/Serialization/JsonApiDeserializer_Benchmarks.cs b/benchmarks/Serialization/JsonApiDeserializer_Benchmarks.cs
index 68f8fd3f36..a2487052d8 100644
--- a/benchmarks/Serialization/JsonApiDeserializer_Benchmarks.cs
+++ b/benchmarks/Serialization/JsonApiDeserializer_Benchmarks.cs
@@ -13,7 +13,6 @@
using Moq;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
-
namespace Benchmarks.Serialization
{
[MarkdownExporter]
diff --git a/src/Examples/NoEntityFrameworkExample/Startup.cs b/src/Examples/NoEntityFrameworkExample/Startup.cs
index b83084e87a..fe73537169 100644
--- a/src/Examples/NoEntityFrameworkExample/Startup.cs
+++ b/src/Examples/NoEntityFrameworkExample/Startup.cs
@@ -57,7 +57,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
context.Database.EnsureCreated();
- app.UseMvc();
+ app.UseJsonApi();
}
}
}
diff --git a/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs b/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs
index cefdc2c419..12eba8f6d0 100644
--- a/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs
+++ b/src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs
@@ -367,27 +367,6 @@ protected void LoadCurrentRelationships(TResource oldEntity, RelationshipAttribu
}
}
- ///
- /// The relationshipValue parameter contains the dependent side of the relationship (Tags).
- /// We can't directly add them to the left entity (Article): we need to
- /// use the join table (ArticleTags). This methods assigns the relationship value to entity
- /// by taking care of that
- ///
- private void AssignHasManyThrough(TResource entity, HasManyThroughAttribute hasManyThrough, IList relationshipValue)
- {
- var pointers = relationshipValue.Cast();
- var throughRelationshipCollection = Activator.CreateInstance(hasManyThrough.ThroughProperty.PropertyType) as IList;
- hasManyThrough.ThroughProperty.SetValue(entity, throughRelationshipCollection);
-
- foreach (var pointer in pointers)
- {
- var throughInstance = Activator.CreateInstance(hasManyThrough.ThroughType);
- hasManyThrough.LeftProperty.SetValue(throughInstance, entity);
- hasManyThrough.RightProperty.SetValue(throughInstance, pointer);
- throughRelationshipCollection.Add(throughInstance);
- }
- }
-
///
/// Given a iidentifiable relationshipvalue, verify if an entity of the underlying
/// type with the same ID is already attached to the dbContext, and if so, return it.
@@ -423,19 +402,15 @@ public class DefaultResourceRepository : DefaultResourceRepository();
dbResolverMock.Setup(m => m.GetContext()).Returns(new Mock().Object);
TestModelRepository._dbContextResolver = dbResolverMock.Object;
+ _services.AddSingleton(new JsonApiOptions());
+ _services.AddScoped((_) => new Mock().Object);
+ _services.AddScoped((_) => new Mock().Object);
+ _services.AddScoped((_) => new Mock().Object);
+ _services.AddScoped((_) => new Mock().Object);
+ _services.AddScoped((_) => new Mock().Object);
+ _services.AddScoped((_) => new Mock().Object);
+ _services.AddScoped((_) => new Mock().Object);
+ _services.AddScoped((_) => new Mock().Object);
+ _services.AddScoped((_) => new Mock().Object);
+ _services.AddScoped((_) => new Mock().Object);
+ _services.AddScoped((_) => new Mock().Object);
}
private ServiceDiscoveryFacade _facade => new ServiceDiscoveryFacade(_services, _resourceGraphBuilder);
@@ -63,13 +80,7 @@ public void AddCurrentAssembly_Adds_Resources_To_Graph()
[Fact]
public void AddCurrentAssembly_Adds_Services_To_Container()
{
- // arrange, act
- _services.AddSingleton(new JsonApiOptions());
-
- _services.AddScoped((_) => new Mock().Object);
- _services.AddScoped((_) => new Mock().Object);
- _services.AddScoped((_) => new Mock().Object);
- _services.AddScoped((_) => new Mock().Object);
+ // arrange, act
_facade.AddCurrentAssembly();
// assert
@@ -93,26 +104,28 @@ public class TestModel : Identifiable { }
public class TestModelService : DefaultResourceService
{
- private static IResourceRepository _repo = new Mock>().Object;
- private static IJsonApiContext _jsonApiContext = new Mock().Object;
+ private static IResourceRepository _repo = new Mock>().Object;
- public TestModelService(
- IResourceRepository repository,
- IJsonApiOptions options,
- IRequestContext currentRequest,
- IPageQueryService pageService,
- IResourceGraph resourceGraph,
- ILoggerFactory loggerFactory = null,
- IResourceHookExecutor hookExecutor = null) : base(repository, options, currentRequest, pageService, resourceGraph, loggerFactory, hookExecutor)
- {
- }
+ public TestModelService(ISortService sortService,
+ IFilterService filterService,
+ IJsonApiOptions options,
+ IIncludeService includeService,
+ ISparseFieldsService sparseFieldsService,
+ IPageService pageManager,
+ IResourceContextProvider provider,
+ IResourceHookExecutor hookExecutor = null,
+ ILoggerFactory loggerFactory = null)
+ : base(sortService, filterService, _repo, options, includeService, sparseFieldsService, pageManager, provider, hookExecutor, loggerFactory) { }
}
public class TestModelRepository : DefaultResourceRepository
{
- internal static IDbContextResolver _dbContextResolver;
- private static IJsonApiContext _jsonApiContext = new Mock().Object;
- public TestModelRepository() : base(_jsonApiContext, _dbContextResolver) { }
+ internal static IDbContextResolver _dbContextResolver;
+
+ public TestModelRepository(ITargetedFields targetedFields,
+ IResourceGraph resourceGraph,
+ IGenericServiceFactory genericServiceFactory)
+ : base(targetedFields, _dbContextResolver, resourceGraph, genericServiceFactory) { }
}
}
}
diff --git a/test/NoEntityFrameworkTests/TestFixture.cs b/test/NoEntityFrameworkTests/TestFixture.cs
index 4903306613..b11f7ff118 100644
--- a/test/NoEntityFrameworkTests/TestFixture.cs
+++ b/test/NoEntityFrameworkTests/TestFixture.cs
@@ -46,14 +46,13 @@ public IResponseDeserializer GetDeserializer()
.AddResource()
.AddResource()
.AddResource()
- .AddResource("todo-items")
+ .AddResource("custom-todo-items")
.AddResource().Build();
return new ResponseDeserializer(resourceGraph);
}
public T GetService() => (T)_services.GetService(typeof(T));
-
public void Dispose()
{
Server.Dispose();