Skip to content

Commit c2cf072

Browse files
author
Bart Koelman
authored
Merge pull request #1131 from json-api-dotnet/small-fixes
Various small corrections
2 parents 510172b + b13c4ff commit c2cf072

File tree

20 files changed

+42
-53
lines changed

20 files changed

+42
-53
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ Closes #{ISSUE_NUMBER}
77
- [ ] Complies with our [contributing guidelines](./.github/CONTRIBUTING.md)
88
- [ ] Adapted tests
99
- [ ] Documentation updated
10-
- [ ] Created issue to update [Templates](https://github.com/json-api-dotnet/Templates/issues/new): {ISSUE_NUMBER}

src/JsonApiDotNetCore/Configuration/TypeLocator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ internal sealed class TypeLocator
8989
private static (Type implementationType, Type serviceInterface)? GetContainerRegistrationFromType(Type nextType, Type unboundInterface,
9090
Type[] interfaceTypeArguments)
9191
{
92-
if (!nextType.IsNested)
92+
if (!nextType.IsNested && !nextType.IsAbstract && !nextType.IsInterface)
9393
{
9494
foreach (Type nextConstructedInterface in nextType.GetInterfaces().Where(type => type.IsGenericType))
9595
{

test/JsonApiDotNetCoreTests/IntegrationTests/HostingInIIS/HostingStartup.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
using JetBrains.Annotations;
22
using JsonApiDotNetCore.Configuration;
33
using Microsoft.AspNetCore.Builder;
4-
using Microsoft.AspNetCore.Hosting;
54
using Microsoft.EntityFrameworkCore;
6-
using Microsoft.Extensions.Logging;
75
using TestBuildingBlocks;
86

97
namespace JsonApiDotNetCoreTests.IntegrationTests.HostingInIIS;
@@ -20,10 +18,10 @@ protected override void SetJsonApiOptions(JsonApiOptions options)
2018
options.IncludeTotalResourceCount = true;
2119
}
2220

23-
public override void Configure(IApplicationBuilder app, IWebHostEnvironment environment, ILoggerFactory loggerFactory)
21+
public override void Configure(IApplicationBuilder app)
2422
{
2523
app.UsePathBase("/iis-application-virtual-directory");
2624

27-
base.Configure(app, environment, loggerFactory);
25+
base.Configure(app);
2826
}
2927
}

test/JsonApiDotNetCoreTests/IntegrationTests/NonJsonApiControllers/DuplicateResourceControllerTests.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,4 @@ public void Fails_at_startup_when_multiple_controllers_exist_for_same_resource_t
2222
// Assert
2323
action.Should().ThrowExactly<InvalidConfigurationException>().WithMessage("Multiple controllers found for resource type 'knownResources'.");
2424
}
25-
26-
public override void Dispose()
27-
{
28-
// Prevents crash when test cleanup tries to access lazily constructed Factory.
29-
}
3025
}

test/JsonApiDotNetCoreTests/IntegrationTests/NonJsonApiControllers/NonJsonApiControllerTests.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public async Task Get_skips_middleware_and_formatters()
2323
// Arrange
2424
using var request = new HttpRequestMessage(HttpMethod.Get, "/NonJsonApi");
2525

26-
HttpClient client = _testContext.Factory.CreateClient();
26+
using HttpClient client = _testContext.Factory.CreateClient();
2727

2828
// Act
29-
HttpResponseMessage httpResponse = await client.SendAsync(request);
29+
using HttpResponseMessage httpResponse = await client.SendAsync(request);
3030

3131
// Assert
3232
httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);
@@ -52,10 +52,10 @@ public async Task Post_skips_middleware_and_formatters()
5252
}
5353
};
5454

55-
HttpClient client = _testContext.Factory.CreateClient();
55+
using HttpClient client = _testContext.Factory.CreateClient();
5656

5757
// Act
58-
HttpResponseMessage httpResponse = await client.SendAsync(request);
58+
using HttpResponseMessage httpResponse = await client.SendAsync(request);
5959

6060
// Assert
6161
httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);
@@ -72,10 +72,10 @@ public async Task Post_skips_error_handler()
7272
// Arrange
7373
using var request = new HttpRequestMessage(HttpMethod.Post, "/NonJsonApi");
7474

75-
HttpClient client = _testContext.Factory.CreateClient();
75+
using HttpClient client = _testContext.Factory.CreateClient();
7676

7777
// Act
78-
HttpResponseMessage httpResponse = await client.SendAsync(request);
78+
using HttpResponseMessage httpResponse = await client.SendAsync(request);
7979

8080
// Assert
8181
httpResponse.Should().HaveStatusCode(HttpStatusCode.BadRequest);
@@ -101,10 +101,10 @@ public async Task Put_skips_middleware_and_formatters()
101101
}
102102
};
103103

104-
HttpClient client = _testContext.Factory.CreateClient();
104+
using HttpClient client = _testContext.Factory.CreateClient();
105105

106106
// Act
107-
HttpResponseMessage httpResponse = await client.SendAsync(request);
107+
using HttpResponseMessage httpResponse = await client.SendAsync(request);
108108

109109
// Assert
110110
httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);
@@ -121,10 +121,10 @@ public async Task Patch_skips_middleware_and_formatters()
121121
// Arrange
122122
using var request = new HttpRequestMessage(HttpMethod.Patch, "/NonJsonApi?name=Janice");
123123

124-
HttpClient client = _testContext.Factory.CreateClient();
124+
using HttpClient client = _testContext.Factory.CreateClient();
125125

126126
// Act
127-
HttpResponseMessage httpResponse = await client.SendAsync(request);
127+
using HttpResponseMessage httpResponse = await client.SendAsync(request);
128128

129129
// Assert
130130
httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);
@@ -141,10 +141,10 @@ public async Task Delete_skips_middleware_and_formatters()
141141
// Arrange
142142
using var request = new HttpRequestMessage(HttpMethod.Delete, "/NonJsonApi");
143143

144-
HttpClient client = _testContext.Factory.CreateClient();
144+
using HttpClient client = _testContext.Factory.CreateClient();
145145

146146
// Act
147-
HttpResponseMessage httpResponse = await client.SendAsync(request);
147+
using HttpResponseMessage httpResponse = await client.SendAsync(request);
148148

149149
// Assert
150150
httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);

test/JsonApiDotNetCoreTests/IntegrationTests/NonJsonApiControllers/UnknownResourceControllerTests.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,4 @@ public void Fails_at_startup_when_using_controller_for_resource_type_that_is_not
2222
action.Should().ThrowExactly<InvalidConfigurationException>().WithMessage($"Controller '{typeof(UnknownResourcesController)}' " +
2323
$"depends on resource type '{typeof(UnknownResource)}', which does not exist in the resource graph.");
2424
}
25-
26-
public override void Dispose()
27-
{
28-
// Prevents crash when test cleanup tries to access lazily constructed Factory.
29-
}
3025
}

test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Blog.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public sealed class Blog : Identifiable<int>
1717
[Attr(Capabilities = AttrCapabilities.All & ~(AttrCapabilities.AllowCreate | AttrCapabilities.AllowChange))]
1818
public bool ShowAdvertisements => PlatformName.EndsWith("(using free account)", StringComparison.Ordinal);
1919

20+
public bool IsPublished { get; set; }
21+
2022
[HasMany]
2123
public IList<BlogPost> Posts { get; set; } = new List<BlogPost>();
2224

test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterDataTypeTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ public FilterDataTypeTests(IntegrationTestContext<TestableStartup<FilterDbContex
2626
var options = (JsonApiOptions)testContext.Factory.Services.GetRequiredService<IJsonApiOptions>();
2727
options.EnableLegacyFilterNotation = false;
2828

29-
if (!options.SerializerOptions.Converters.Any(converter => converter is JsonStringEnumMemberConverter))
29+
if (!options.SerializerOptions.Converters.Any(converter => converter is JsonStringEnumConverter))
3030
{
31-
options.SerializerOptions.Converters.Add(new JsonStringEnumMemberConverter());
32-
options.SerializerOptions.Converters.Add(new JsonTimeSpanConverter());
31+
options.SerializerOptions.Converters.Add(new JsonStringEnumConverter());
3332
}
3433
}
3534

test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/LabelColor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace JsonApiDotNetCoreTests.IntegrationTests.QueryStrings;
55

66
[UsedImplicitly(ImplicitUseTargetFlags.Members)]
7-
[JsonConverter(typeof(JsonStringEnumMemberConverter))]
7+
[JsonConverter(typeof(JsonStringEnumConverter))]
88
public enum LabelColor
99
{
1010
Red,

test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/SparseFieldSets/SparseFieldSetTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@ public async Task Retrieves_all_properties_when_fieldset_contains_readonly_attri
749749
store.Clear();
750750

751751
Blog blog = _fakers.Blog.Generate();
752+
blog.IsPublished = true;
752753

753754
await _testContext.RunOnDatabaseAsync(async dbContext =>
754755
{
@@ -771,7 +772,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
771772
responseDocument.Data.SingleValue.Relationships.Should().BeNull();
772773

773774
var blogCaptured = (Blog)store.Resources.Should().ContainSingle(resource => resource is Blog).And.Subject.Single();
774-
blogCaptured.ShowAdvertisements.Should().Be(blogCaptured.ShowAdvertisements);
775+
blogCaptured.ShowAdvertisements.Should().Be(blog.ShowAdvertisements);
776+
blogCaptured.IsPublished.Should().Be(blog.IsPublished);
775777
blogCaptured.Title.Should().Be(blog.Title);
776778
}
777779

@@ -817,7 +819,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
817819
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).And.Subject.Single();
818820
postCaptured.Id.Should().Be(post.Id);
819821
postCaptured.Caption.Should().Be(post.Caption);
820-
postCaptured.Url.Should().Be(postCaptured.Url);
822+
postCaptured.Url.Should().Be(post.Url);
821823
}
822824

823825
[Fact]

0 commit comments

Comments
 (0)