Skip to content

Commit f179362

Browse files
committed
Convert legacy unit tests
1 parent 164c87e commit f179362

File tree

1 file changed

+10
-29
lines changed

1 file changed

+10
-29
lines changed

test/UnitTests/Extensions/ServiceCollectionExtensionsTests.cs renamed to test/JsonApiDotNetCoreTests/UnitTests/Configuration/ServiceCollectionExtensionsTests.cs

+10-29
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
using TestBuildingBlocks;
1616
using Xunit;
1717

18-
namespace UnitTests.Extensions;
18+
namespace JsonApiDotNetCoreTests.UnitTests.Configuration;
1919

2020
public sealed class ServiceCollectionExtensionsTests
2121
{
2222
[Fact]
23-
public void RegisterResource_DeviatingDbContextPropertyName_RegistersCorrectly()
23+
public void Register_resource_from_DbContext_ignores_deviating_DbContext_property_name()
2424
{
2525
// Arrange
2626
var services = new ServiceCollection();
@@ -39,7 +39,7 @@ public void RegisterResource_DeviatingDbContextPropertyName_RegistersCorrectly()
3939
}
4040

4141
[Fact]
42-
public void AddResourceService_Registers_Service_Interfaces_Of_Int32()
42+
public void Can_register_resource_service_for_Id_type_Int32()
4343
{
4444
// Arrange
4545
var services = new ServiceCollection();
@@ -63,7 +63,7 @@ public void AddResourceService_Registers_Service_Interfaces_Of_Int32()
6363
}
6464

6565
[Fact]
66-
public void AddResourceService_Registers_Service_Interfaces_Of_Guid()
66+
public void Can_register_resource_service_for_Id_type_Guid()
6767
{
6868
// Arrange
6969
var services = new ServiceCollection();
@@ -87,7 +87,7 @@ public void AddResourceService_Registers_Service_Interfaces_Of_Guid()
8787
}
8888

8989
[Fact]
90-
public void AddResourceService_Throws_If_Type_Does_Not_Implement_Any_Interfaces()
90+
public void Cannot_register_resource_service_for_type_that_does_not_implement_required_interfaces()
9191
{
9292
// Arrange
9393
var services = new ServiceCollection();
@@ -101,7 +101,7 @@ public void AddResourceService_Throws_If_Type_Does_Not_Implement_Any_Interfaces(
101101
}
102102

103103
[Fact]
104-
public void AddResourceRepository_Registers_Repository_Interfaces_Of_Int32()
104+
public void Can_register_resource_repository_for_Id_type_Int32()
105105
{
106106
// Arrange
107107
var services = new ServiceCollection();
@@ -118,7 +118,7 @@ public void AddResourceRepository_Registers_Repository_Interfaces_Of_Int32()
118118
}
119119

120120
[Fact]
121-
public void AddResourceRepository_Registers_Repository_Interfaces_Of_Guid()
121+
public void Can_register_resource_repository_for_Id_type_Guid()
122122
{
123123
// Arrange
124124
var services = new ServiceCollection();
@@ -135,7 +135,7 @@ public void AddResourceRepository_Registers_Repository_Interfaces_Of_Guid()
135135
}
136136

137137
[Fact]
138-
public void AddResourceDefinition_Registers_Definition_Interface_Of_Int32()
138+
public void Can_register_resource_definition_for_Id_type_Int32()
139139
{
140140
// Arrange
141141
var services = new ServiceCollection();
@@ -150,7 +150,7 @@ public void AddResourceDefinition_Registers_Definition_Interface_Of_Int32()
150150
}
151151

152152
[Fact]
153-
public void AddResourceDefinition_Registers_Definition_Interface_Of_Guid()
153+
public void Can_register_resource_definition_for_Id_type_Guid()
154154
{
155155
// Arrange
156156
var services = new ServiceCollection();
@@ -164,25 +164,6 @@ public void AddResourceDefinition_Registers_Definition_Interface_Of_Guid()
164164
provider.GetRequiredService(typeof(IResourceDefinition<ResourceOfGuid, Guid>)).Should().BeOfType<ResourceDefinitionOfGuid>();
165165
}
166166

167-
[Fact]
168-
public void AddJsonApi_With_Context_Uses_Resource_Type_Name_If_NoOtherSpecified()
169-
{
170-
// Arrange
171-
var services = new ServiceCollection();
172-
services.AddLogging();
173-
services.AddDbContext<TestDbContext>(options => options.UseInMemoryDatabase(Guid.NewGuid().ToString()));
174-
175-
// Act
176-
services.AddJsonApi<TestDbContext>();
177-
178-
// Assert
179-
ServiceProvider provider = services.BuildServiceProvider();
180-
var resourceGraph = provider.GetRequiredService<IResourceGraph>();
181-
ResourceType resourceType = resourceGraph.GetResourceType(typeof(ResourceOfInt32));
182-
183-
resourceType.PublicName.Should().Be("resourceOfInt32s");
184-
}
185-
186167
private sealed class ResourceOfInt32 : Identifiable<int>
187168
{
188169
}
@@ -594,7 +575,7 @@ private sealed class TestDbContext : TestableDbContext
594575
{
595576
public DbSet<ResourceOfInt32> ResourcesOfInt32 => Set<ResourceOfInt32>();
596577
public DbSet<ResourceOfGuid> ResourcesOfGuid => Set<ResourceOfGuid>();
597-
public DbSet<Person> People => Set<Person>();
578+
public DbSet<Person> SetOfPersons => Set<Person>();
598579

599580
public TestDbContext(DbContextOptions<TestDbContext> options)
600581
: base(options)

0 commit comments

Comments
 (0)