Skip to content

Commit 66a2dc4

Browse files
committed
Merge branch 'master' into openapi-required-and-nullable-properties
2 parents c3c4844 + 923fbd8 commit 66a2dc4

File tree

11 files changed

+33
-33
lines changed

11 files changed

+33
-33
lines changed

src/JsonApiDotNetCore/Middleware/HeaderConstants.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ namespace JsonApiDotNetCore.Middleware;
88
public static class HeaderConstants
99
{
1010
public const string MediaType = "application/vnd.api+json";
11-
public const string AtomicOperationsMediaType = MediaType + "; ext=\"https://jsonapi.org/ext/atomic\"";
11+
public const string AtomicOperationsMediaType = $"{MediaType}; ext=\"https://jsonapi.org/ext/atomic\"";
1212
}

test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/ModelStateValidationTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public async Task Cannot_create_resource_with_invalid_attribute_value()
125125
ErrorObject error = responseDocument.Errors[0];
126126
error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity);
127127
error.Title.Should().Be("Input validation failed.");
128-
error.Detail.Should().Be("The field Name must match the regular expression '^[\\w\\s]+$'.");
128+
error.Detail.Should().Be(@"The field Name must match the regular expression '^[\w\s]+$'.");
129129
error.Source.ShouldNotBeNull();
130130
error.Source.Pointer.Should().Be("/data/attributes/directoryName");
131131
}
@@ -534,7 +534,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
534534
ErrorObject error = responseDocument.Errors[0];
535535
error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity);
536536
error.Title.Should().Be("Input validation failed.");
537-
error.Detail.Should().Be("The field Name must match the regular expression '^[\\w\\s]+$'.");
537+
error.Detail.Should().Be(@"The field Name must match the regular expression '^[\w\s]+$'.");
538538
error.Source.ShouldNotBeNull();
539539
error.Source.Pointer.Should().Be("/data/attributes/directoryName");
540540
}

test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/KebabCasingTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
7474
await dbContext.SaveChangesAsync();
7575
});
7676

77-
string route = $"/public-api/swimming-pools/{pool.StringId}/water-slides" +
78-
"?filter=greaterThan(length-in-meters,'1')&fields[water-slides]=length-in-meters";
77+
string route =
78+
$"/public-api/swimming-pools/{pool.StringId}/water-slides?filter=greaterThan(length-in-meters,'1')&fields[water-slides]=length-in-meters";
7979

8080
// Act
8181
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);

test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/PascalCasingTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
7979
await dbContext.SaveChangesAsync();
8080
});
8181

82-
string route = $"/PublicApi/SwimmingPools/{pool.StringId}/WaterSlides" + "?filter=greaterThan(LengthInMeters,'1')&fields[WaterSlides]=LengthInMeters";
82+
string route = $"/PublicApi/SwimmingPools/{pool.StringId}/WaterSlides?filter=greaterThan(LengthInMeters,'1')&fields[WaterSlides]=LengthInMeters";
8383

8484
// Act
8585
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);

test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/PaginationWithTotalCountTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
323323

324324
responseDocument.Links.ShouldNotBeNull();
325325
responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}");
326-
responseDocument.Links.First.Should().Be(basePath + "?page%5Bsize%5D=1");
326+
responseDocument.Links.First.Should().Be($"{basePath}?page%5Bsize%5D=1");
327327
responseDocument.Links.Last.Should().BeNull();
328328
responseDocument.Links.Prev.Should().Be(responseDocument.Links.First);
329-
responseDocument.Links.Next.Should().Be(basePath + "?page%5Bnumber%5D=3&page%5Bsize%5D=1");
329+
responseDocument.Links.Next.Should().Be($"{basePath}?page%5Bnumber%5D=3&page%5Bsize%5D=1");
330330
}
331331

332332
[Fact]

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

+15-15
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
7171
value.Links.Related.ShouldNotBeNull();
7272
});
7373

74-
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).And.Subject.Single();
74+
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which;
7575
postCaptured.Caption.Should().Be(post.Caption);
7676
postCaptured.Url.Should().BeNull();
7777
}
@@ -106,7 +106,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
106106
responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(post.Caption));
107107
responseDocument.Data.ManyValue[0].Relationships.Should().BeNull();
108108

109-
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).And.Subject.Single();
109+
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which;
110110
postCaptured.Caption.Should().Be(post.Caption);
111111
postCaptured.Url.Should().BeNull();
112112
}
@@ -149,7 +149,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
149149
value.Links.Related.ShouldNotBeNull();
150150
});
151151

152-
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).And.Subject.Single();
152+
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which;
153153
postCaptured.Caption.Should().BeNull();
154154
postCaptured.Url.Should().BeNull();
155155
}
@@ -193,7 +193,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
193193
value.Links.Related.ShouldNotBeNull();
194194
});
195195

196-
var blogCaptured = (Blog)store.Resources.Should().ContainSingle(resource => resource is Blog).And.Subject.Single();
196+
var blogCaptured = (Blog)store.Resources.Should().ContainSingle(resource => resource is Blog).Which;
197197
blogCaptured.Id.Should().Be(blog.Id);
198198
blogCaptured.Title.Should().BeNull();
199199

@@ -240,7 +240,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
240240
value.Links.Related.ShouldNotBeNull();
241241
});
242242

243-
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).And.Subject.Single();
243+
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which;
244244
postCaptured.Url.Should().Be(post.Url);
245245
postCaptured.Caption.Should().BeNull();
246246
}
@@ -299,7 +299,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
299299
value.Links.Related.ShouldNotBeNull();
300300
});
301301

302-
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).And.Subject.Single();
302+
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which;
303303
postCaptured.Id.Should().Be(post.Id);
304304
postCaptured.Caption.Should().Be(post.Caption);
305305

@@ -361,7 +361,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
361361
value.Links.Related.ShouldNotBeNull();
362362
});
363363

364-
var accountCaptured = (WebAccount)store.Resources.Should().ContainSingle(resource => resource is WebAccount).And.Subject.Single();
364+
var accountCaptured = (WebAccount)store.Resources.Should().ContainSingle(resource => resource is WebAccount).Which;
365365
accountCaptured.Id.Should().Be(account.Id);
366366
accountCaptured.DisplayName.Should().Be(account.DisplayName);
367367

@@ -423,7 +423,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
423423
value.Links.Related.ShouldNotBeNull();
424424
});
425425

426-
var blogCaptured = (Blog)store.Resources.Should().ContainSingle(resource => resource is Blog).And.Subject.Single();
426+
var blogCaptured = (Blog)store.Resources.Should().ContainSingle(resource => resource is Blog).Which;
427427
blogCaptured.Id.Should().Be(blog.Id);
428428
blogCaptured.Owner.ShouldNotBeNull();
429429
blogCaptured.Owner.DisplayName.Should().Be(blog.Owner.DisplayName);
@@ -476,7 +476,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
476476
responseDocument.Included[0].Attributes.ShouldContainKey("color").With(value => value.Should().Be(post.Labels.Single().Color));
477477
responseDocument.Included[0].Relationships.Should().BeNull();
478478

479-
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).And.Subject.Single();
479+
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which;
480480
postCaptured.Id.Should().Be(post.Id);
481481
postCaptured.Caption.Should().Be(post.Caption);
482482

@@ -532,7 +532,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
532532
responseDocument.Included[1].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(blog.Owner.Posts[0].Caption));
533533
responseDocument.Included[1].Relationships.Should().BeNull();
534534

535-
var blogCaptured = (Blog)store.Resources.Should().ContainSingle(resource => resource is Blog).And.Subject.Single();
535+
var blogCaptured = (Blog)store.Resources.Should().ContainSingle(resource => resource is Blog).Which;
536536
blogCaptured.Id.Should().Be(blog.Id);
537537
blogCaptured.Title.Should().Be(blog.Title);
538538
blogCaptured.PlatformName.Should().BeNull();
@@ -620,7 +620,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
620620
value.Links.Related.ShouldNotBeNull();
621621
});
622622

623-
var blogCaptured = (Blog)store.Resources.Should().ContainSingle(resource => resource is Blog).And.Subject.Single();
623+
var blogCaptured = (Blog)store.Resources.Should().ContainSingle(resource => resource is Blog).Which;
624624
blogCaptured.Id.Should().Be(blog.Id);
625625
blogCaptured.Title.Should().Be(blog.Title);
626626
blogCaptured.PlatformName.Should().BeNull();
@@ -656,7 +656,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
656656
responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(post.Caption));
657657
responseDocument.Data.ManyValue[0].Relationships.Should().BeNull();
658658

659-
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).And.Subject.Single();
659+
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which;
660660
postCaptured.Id.Should().Be(post.Id);
661661
postCaptured.Caption.Should().Be(post.Caption);
662662
postCaptured.Url.Should().BeNull();
@@ -691,7 +691,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
691691
responseDocument.Data.ManyValue[0].Attributes.Should().BeNull();
692692
responseDocument.Data.ManyValue[0].Relationships.Should().BeNull();
693693

694-
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).And.Subject.Single();
694+
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which;
695695
postCaptured.Id.Should().Be(post.Id);
696696
postCaptured.Url.Should().BeNull();
697697
}
@@ -824,7 +824,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
824824
responseDocument.Data.SingleValue.Attributes.ShouldContainKey("showAdvertisements").With(value => value.Should().Be(blog.ShowAdvertisements));
825825
responseDocument.Data.SingleValue.Relationships.Should().BeNull();
826826

827-
var blogCaptured = (Blog)store.Resources.Should().ContainSingle(resource => resource is Blog).And.Subject.Single();
827+
var blogCaptured = (Blog)store.Resources.Should().ContainSingle(resource => resource is Blog).Which;
828828
blogCaptured.ShowAdvertisements.Should().Be(blog.ShowAdvertisements);
829829
blogCaptured.IsPublished.Should().Be(blog.IsPublished);
830830
blogCaptured.Title.Should().Be(blog.Title);
@@ -869,7 +869,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
869869
value.Links.Related.ShouldNotBeNull();
870870
});
871871

872-
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).And.Subject.Single();
872+
var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which;
873873
postCaptured.Id.Should().Be(post.Id);
874874
postCaptured.Caption.Should().Be(post.Caption);
875875
postCaptured.Url.Should().Be(post.Url);

test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ public async Task Cannot_create_resource_on_unknown_resource_type_in_url()
684684
}
685685
};
686686

687-
const string route = "/" + Unknown.ResourceType;
687+
const string route = $"/{Unknown.ResourceType}";
688688

689689
// Act
690690
(HttpResponseMessage httpResponse, string responseDocument) = await _testContext.ExecutePostAsync<string>(route, requestBody);

test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Fetching/FetchResourceTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
6262
public async Task Cannot_get_primary_resources_for_unknown_type()
6363
{
6464
// Arrange
65-
const string route = "/" + Unknown.ResourceType;
65+
const string route = $"/{Unknown.ResourceType}";
6666

6767
// Act
6868
(HttpResponseMessage httpResponse, string responseDocument) = await _testContext.ExecuteGetAsync<string>(route);

test/JsonApiDotNetCoreTests/UnitTests/FieldChains/FieldChainPatternParseTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void ParseFails(string patternText, string errorMessage)
4949
Action action = () => FieldChainPattern.Parse(patternSource.Text);
5050

5151
// Assert
52-
PatternFormatException exception = action.Should().Throw<PatternFormatException>().Which;
52+
PatternFormatException exception = action.Should().ThrowExactly<PatternFormatException>().Which;
5353
exception.Message.Should().Be(errorMessage);
5454
exception.Position.Should().Be(patternSource.Position);
5555
exception.Pattern.Should().Be(patternSource.Text);

test/JsonApiDotNetCoreTests/UnitTests/Queries/QueryExpressionRewriterTests.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void VisitInclude(string expressionText, string expectedTypes)
5353

5454
// Assert
5555
List<string> visitedTypeNames = rewriter.ExpressionsVisited.Select(queryExpression => queryExpression.GetType().Name).ToList();
56-
List<string> expectedTypeNames = expectedTypes.Split(',').Select(type => type + "Expression").ToList();
56+
List<string> expectedTypeNames = expectedTypes.Split(',').Select(type => $"{type}Expression").ToList();
5757

5858
visitedTypeNames.Should().ContainInOrder(expectedTypeNames);
5959
visitedTypeNames.Should().HaveCount(expectedTypeNames.Count);
@@ -76,7 +76,7 @@ public void VisitSparseFieldSet(string expressionText, string expectedTypes)
7676

7777
// Assert
7878
List<string> visitedTypeNames = rewriter.ExpressionsVisited.Select(queryExpression => queryExpression.GetType().Name).ToList();
79-
List<string> expectedTypeNames = expectedTypes.Split(',').Select(type => type + "Expression").ToList();
79+
List<string> expectedTypeNames = expectedTypes.Split(',').Select(type => $"{type}Expression").ToList();
8080

8181
visitedTypeNames.Should().ContainInOrder(expectedTypeNames);
8282
visitedTypeNames.Should().HaveCount(expectedTypeNames.Count);
@@ -136,7 +136,7 @@ public void VisitFilter(string expressionText, string expectedTypes)
136136

137137
// Assert
138138
List<string> visitedTypeNames = rewriter.ExpressionsVisited.Select(queryExpression => queryExpression.GetType().Name).ToList();
139-
List<string> expectedTypeNames = expectedTypes.Split(',').Select(type => type + "Expression").ToList();
139+
List<string> expectedTypeNames = expectedTypes.Split(',').Select(type => $"{type}Expression").ToList();
140140

141141
visitedTypeNames.Should().ContainInOrder(expectedTypeNames);
142142
visitedTypeNames.Should().HaveCount(expectedTypeNames.Count);
@@ -160,7 +160,7 @@ public void VisitSort(string expressionText, string expectedTypes)
160160

161161
// Assert
162162
List<string> visitedTypeNames = rewriter.ExpressionsVisited.Select(queryExpression => queryExpression.GetType().Name).ToList();
163-
List<string> expectedTypeNames = expectedTypes.Split(',').Select(type => type + "Expression").ToList();
163+
List<string> expectedTypeNames = expectedTypes.Split(',').Select(type => $"{type}Expression").ToList();
164164

165165
visitedTypeNames.Should().ContainInOrder(expectedTypeNames);
166166
visitedTypeNames.Should().HaveCount(expectedTypeNames.Count);
@@ -183,7 +183,7 @@ public void VisitPagination(string expressionText, string expectedTypes)
183183

184184
// Assert
185185
List<string> visitedTypeNames = rewriter.ExpressionsVisited.Select(queryExpression => queryExpression.GetType().Name).ToList();
186-
List<string> expectedTypeNames = expectedTypes.Split(',').Select(type => type + "Expression").ToList();
186+
List<string> expectedTypeNames = expectedTypes.Split(',').Select(type => $"{type}Expression").ToList();
187187

188188
visitedTypeNames.Should().ContainInOrder(expectedTypeNames);
189189
visitedTypeNames.Should().HaveCount(expectedTypeNames.Count);
@@ -208,7 +208,7 @@ public void VisitParameterScope(string expressionText, string expectedTypes)
208208

209209
// Assert
210210
List<string> visitedTypeNames = rewriter.ExpressionsVisited.Select(queryExpression => queryExpression.GetType().Name).ToList();
211-
List<string> expectedTypeNames = expectedTypes.Split(',').Select(type => type + "Expression").ToList();
211+
List<string> expectedTypeNames = expectedTypes.Split(',').Select(type => $"{type}Expression").ToList();
212212

213213
visitedTypeNames.Should().ContainInOrder(expectedTypeNames);
214214
visitedTypeNames.Should().HaveCount(expectedTypeNames.Count);

test/JsonApiDotNetCoreTests/UnitTests/ResourceDefinitions/CreateSortExpressionFromLambdaTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public void Cannot_convert_concatenation_operator()
317317
// Act
318318
Action action = () => resourceDefinition.GetSortExpressionFromLambda(new JsonApiResourceDefinition<FileEntry, long>.PropertySortOrder
319319
{
320-
(file => file.Name + ":" + file.Content, ListSortDirection.Ascending)
320+
(file => $"{file.Name}:{file.Content}", ListSortDirection.Ascending)
321321
});
322322

323323
// Assert

0 commit comments

Comments
 (0)