@@ -112,8 +112,26 @@ public void AddResourceService_Throws_If_Type_Does_Not_Implement_Any_Interfaces(
112112 Assert . Throws < JsonApiSetupException > ( ( ) => services . AddResourceService < int > ( ) ) ;
113113 }
114114
115- private class IntResource : Identifiable { }
116- private class GuidResource : Identifiable < Guid > { }
115+ [ Fact ]
116+ public void AddJsonApi_With_Context_Uses_DbSet_PropertyName_If_NoOtherSpecified ( )
117+ {
118+ // arrange
119+ var services = new ServiceCollection ( ) ;
120+
121+ services . AddScoped < IScopedServiceProvider , TestScopedServiceProvider > ( ) ;
122+
123+ // act
124+ services . AddJsonApi < TestContext > ( ) ;
125+
126+ // assert
127+ var provider = services . BuildServiceProvider ( ) ;
128+ var graph = provider . GetService < IContextGraph > ( ) ;
129+ var resource = graph . GetContextEntity ( typeof ( IntResource ) ) ;
130+ Assert . Equal ( "resource" , resource . EntityName ) ;
131+ }
132+
133+ public class IntResource : Identifiable { }
134+ public class GuidResource : Identifiable < Guid > { }
117135
118136 private class IntResourceService : IResourceService < IntResource >
119137 {
@@ -138,5 +156,11 @@ private class GuidResourceService : IResourceService<GuidResource, Guid>
138156 public Task < GuidResource > UpdateAsync ( Guid id , GuidResource entity ) => throw new NotImplementedException ( ) ;
139157 public Task UpdateRelationshipsAsync ( Guid id , string relationshipName , List < ResourceObject > relationships ) => throw new NotImplementedException ( ) ;
140158 }
159+
160+
161+ public class TestContext : DbContext
162+ {
163+ public DbSet < IntResource > Resource { get ; set ; }
164+ }
141165 }
142166}
0 commit comments