Skip to content

Commit b9db066

Browse files
author
Bart Koelman
committed
Re-align similar testsets
1 parent 45fef9c commit b9db066

File tree

4 files changed

+110
-102
lines changed

4 files changed

+110
-102
lines changed

test/JsonApiDotNetCoreTests/IntegrationTests/Links/AbsoluteLinksWithNamespaceTests.cs

+19-18
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public sealed class AbsoluteLinksWithNamespaceTests
1919
: IClassFixture<IntegrationTestContext<AbsoluteLinksInApiNamespaceStartup<LinksDbContext>, LinksDbContext>>
2020
{
2121
private const string HostPrefix = "http://localhost";
22+
private const string PathPrefix = "/api";
2223

2324
private readonly IntegrationTestContext<AbsoluteLinksInApiNamespaceStartup<LinksDbContext>, LinksDbContext> _testContext;
2425
private readonly LinksFakers _fakers = new();
@@ -51,7 +52,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
5152
await dbContext.SaveChangesAsync();
5253
});
5354

54-
string route = $"/api/photoAlbums/{album.StringId}";
55+
string route = $"{PathPrefix}/photoAlbums/{album.StringId}";
5556

5657
// Act
5758
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
@@ -86,7 +87,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
8687
await dbContext.SaveChangesAsync();
8788
});
8889

89-
const string route = "/api/photoAlbums?include=photos";
90+
string route = $"{PathPrefix}/photoAlbums?include=photos";
9091

9192
// Act
9293
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
@@ -101,14 +102,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
101102
responseDocument.Links.Prev.Should().BeNull();
102103
responseDocument.Links.Next.Should().BeNull();
103104

104-
string albumLink = $"{HostPrefix}/api/photoAlbums/{album.StringId}";
105+
string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{album.StringId}";
105106

106107
responseDocument.Data.ManyValue.ShouldHaveCount(1);
107108
responseDocument.Data.ManyValue[0].Links.Self.Should().Be(albumLink);
108109
responseDocument.Data.ManyValue[0].Relationships["photos"].Links.Self.Should().Be($"{albumLink}/relationships/photos");
109110
responseDocument.Data.ManyValue[0].Relationships["photos"].Links.Related.Should().Be($"{albumLink}/photos");
110111

111-
string photoLink = $"{HostPrefix}/api/photos/{album.Photos.ElementAt(0).StringId}";
112+
string photoLink = $"{HostPrefix}{PathPrefix}/photos/{album.Photos.ElementAt(0).StringId}";
112113

113114
responseDocument.Included.ShouldHaveCount(1);
114115
responseDocument.Included[0].Links.Self.Should().Be(photoLink);
@@ -129,7 +130,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
129130
await dbContext.SaveChangesAsync();
130131
});
131132

132-
string route = $"/api/photos/{photo.StringId}/album";
133+
string route = $"{PathPrefix}/photos/{photo.StringId}/album";
133134

134135
// Act
135136
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
@@ -144,7 +145,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
144145
responseDocument.Links.Prev.Should().BeNull();
145146
responseDocument.Links.Next.Should().BeNull();
146147

147-
string albumLink = $"{HostPrefix}/api/photoAlbums/{photo.Album.StringId}";
148+
string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{photo.Album.StringId}";
148149

149150
responseDocument.Data.SingleValue.ShouldNotBeNull();
150151
responseDocument.Data.SingleValue.Links.Self.Should().Be(albumLink);
@@ -165,7 +166,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
165166
await dbContext.SaveChangesAsync();
166167
});
167168

168-
string route = $"/api/photoAlbums/{album.StringId}/photos";
169+
string route = $"{PathPrefix}/photoAlbums/{album.StringId}/photos";
169170

170171
// Act
171172
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
@@ -180,7 +181,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
180181
responseDocument.Links.Prev.Should().BeNull();
181182
responseDocument.Links.Next.Should().BeNull();
182183

183-
string photoLink = $"{HostPrefix}/api/photos/{album.Photos.ElementAt(0).StringId}";
184+
string photoLink = $"{HostPrefix}{PathPrefix}/photos/{album.Photos.ElementAt(0).StringId}";
184185

185186
responseDocument.Data.ManyValue.ShouldHaveCount(1);
186187
responseDocument.Data.ManyValue[0].Links.Self.Should().Be(photoLink);
@@ -201,7 +202,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
201202
await dbContext.SaveChangesAsync();
202203
});
203204

204-
string route = $"/api/photos/{photo.StringId}/relationships/album";
205+
string route = $"{PathPrefix}/photos/{photo.StringId}/relationships/album";
205206

206207
// Act
207208
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
@@ -210,7 +211,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
210211
httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);
211212

212213
responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}");
213-
responseDocument.Links.Related.Should().Be($"{HostPrefix}/api/photos/{photo.StringId}/album");
214+
responseDocument.Links.Related.Should().Be($"{HostPrefix}{PathPrefix}/photos/{photo.StringId}/album");
214215
responseDocument.Links.First.Should().BeNull();
215216
responseDocument.Links.Last.Should().BeNull();
216217
responseDocument.Links.Prev.Should().BeNull();
@@ -234,7 +235,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
234235
await dbContext.SaveChangesAsync();
235236
});
236237

237-
string route = $"/api/photoAlbums/{album.StringId}/relationships/photos";
238+
string route = $"{PathPrefix}/photoAlbums/{album.StringId}/relationships/photos";
238239

239240
// Act
240241
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
@@ -243,7 +244,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
243244
httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);
244245

245246
responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}");
246-
responseDocument.Links.Related.Should().Be($"{HostPrefix}/api/photoAlbums/{album.StringId}/photos");
247+
responseDocument.Links.Related.Should().Be($"{HostPrefix}{PathPrefix}/photoAlbums/{album.StringId}/photos");
247248
responseDocument.Links.First.Should().Be($"{HostPrefix}{route}");
248249
responseDocument.Links.Last.Should().BeNull();
249250
responseDocument.Links.Prev.Should().BeNull();
@@ -288,7 +289,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
288289
}
289290
};
290291

291-
const string route = "/api/photoAlbums?include=photos";
292+
string route = $"{PathPrefix}/photoAlbums?include=photos";
292293

293294
// Act
294295
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecutePostAsync<Document>(route, requestBody);
@@ -303,13 +304,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
303304
responseDocument.Links.Prev.Should().BeNull();
304305
responseDocument.Links.Next.Should().BeNull();
305306

306-
string albumLink = $"{HostPrefix}/api/photoAlbums/{responseDocument.Data.SingleValue.Id}";
307+
string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{responseDocument.Data.SingleValue.Id}";
307308

308309
responseDocument.Data.SingleValue.Links.Self.Should().Be(albumLink);
309310
responseDocument.Data.SingleValue.Relationships["photos"].Links.Self.Should().Be($"{albumLink}/relationships/photos");
310311
responseDocument.Data.SingleValue.Relationships["photos"].Links.Related.Should().Be($"{albumLink}/photos");
311312

312-
string photoLink = $"{HostPrefix}/api/photos/{existingPhoto.StringId}";
313+
string photoLink = $"{HostPrefix}{PathPrefix}/photos/{existingPhoto.StringId}";
313314

314315
responseDocument.Included.ShouldHaveCount(1);
315316
responseDocument.Included[0].Links.Self.Should().Be(photoLink);
@@ -350,7 +351,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
350351
}
351352
};
352353

353-
string route = $"/api/photos/{existingPhoto.StringId}?include=album";
354+
string route = $"{PathPrefix}/photos/{existingPhoto.StringId}?include=album";
354355

355356
// Act
356357
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecutePatchAsync<Document>(route, requestBody);
@@ -365,14 +366,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
365366
responseDocument.Links.Prev.Should().BeNull();
366367
responseDocument.Links.Next.Should().BeNull();
367368

368-
string photoLink = $"{HostPrefix}/api/photos/{existingPhoto.StringId}";
369+
string photoLink = $"{HostPrefix}{PathPrefix}/photos/{existingPhoto.StringId}";
369370

370371
responseDocument.Data.SingleValue.ShouldNotBeNull();
371372
responseDocument.Data.SingleValue.Links.Self.Should().Be(photoLink);
372373
responseDocument.Data.SingleValue.Relationships["album"].Links.Self.Should().Be($"{photoLink}/relationships/album");
373374
responseDocument.Data.SingleValue.Relationships["album"].Links.Related.Should().Be($"{photoLink}/album");
374375

375-
string albumLink = $"{HostPrefix}/api/photoAlbums/{existingAlbum.StringId}";
376+
string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{existingAlbum.StringId}";
376377

377378
responseDocument.Included.ShouldHaveCount(1);
378379
responseDocument.Included[0].Links.Self.Should().Be(albumLink);

test/JsonApiDotNetCoreTests/IntegrationTests/Links/AbsoluteLinksWithoutNamespaceTests.cs

+19-18
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public sealed class AbsoluteLinksWithoutNamespaceTests
1919
: IClassFixture<IntegrationTestContext<AbsoluteLinksNoNamespaceStartup<LinksDbContext>, LinksDbContext>>
2020
{
2121
private const string HostPrefix = "http://localhost";
22+
private const string PathPrefix = "";
2223

2324
private readonly IntegrationTestContext<AbsoluteLinksNoNamespaceStartup<LinksDbContext>, LinksDbContext> _testContext;
2425
private readonly LinksFakers _fakers = new();
@@ -51,7 +52,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
5152
await dbContext.SaveChangesAsync();
5253
});
5354

54-
string route = $"/photoAlbums/{album.StringId}";
55+
string route = $"{PathPrefix}/photoAlbums/{album.StringId}";
5556

5657
// Act
5758
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
@@ -86,7 +87,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
8687
await dbContext.SaveChangesAsync();
8788
});
8889

89-
const string route = "/photoAlbums?include=photos";
90+
string route = $"{PathPrefix}/photoAlbums?include=photos";
9091

9192
// Act
9293
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
@@ -101,14 +102,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
101102
responseDocument.Links.Prev.Should().BeNull();
102103
responseDocument.Links.Next.Should().BeNull();
103104

104-
string albumLink = $"{HostPrefix}/photoAlbums/{album.StringId}";
105+
string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{album.StringId}";
105106

106107
responseDocument.Data.ManyValue.ShouldHaveCount(1);
107108
responseDocument.Data.ManyValue[0].Links.Self.Should().Be(albumLink);
108109
responseDocument.Data.ManyValue[0].Relationships["photos"].Links.Self.Should().Be($"{albumLink}/relationships/photos");
109110
responseDocument.Data.ManyValue[0].Relationships["photos"].Links.Related.Should().Be($"{albumLink}/photos");
110111

111-
string photoLink = $"{HostPrefix}/photos/{album.Photos.ElementAt(0).StringId}";
112+
string photoLink = $"{HostPrefix}{PathPrefix}/photos/{album.Photos.ElementAt(0).StringId}";
112113

113114
responseDocument.Included.ShouldHaveCount(1);
114115
responseDocument.Included[0].Links.Self.Should().Be(photoLink);
@@ -129,7 +130,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
129130
await dbContext.SaveChangesAsync();
130131
});
131132

132-
string route = $"/photos/{photo.StringId}/album";
133+
string route = $"{PathPrefix}/photos/{photo.StringId}/album";
133134

134135
// Act
135136
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
@@ -144,7 +145,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
144145
responseDocument.Links.Prev.Should().BeNull();
145146
responseDocument.Links.Next.Should().BeNull();
146147

147-
string albumLink = $"{HostPrefix}/photoAlbums/{photo.Album.StringId}";
148+
string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{photo.Album.StringId}";
148149

149150
responseDocument.Data.SingleValue.ShouldNotBeNull();
150151
responseDocument.Data.SingleValue.Links.Self.Should().Be(albumLink);
@@ -165,7 +166,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
165166
await dbContext.SaveChangesAsync();
166167
});
167168

168-
string route = $"/photoAlbums/{album.StringId}/photos";
169+
string route = $"{PathPrefix}/photoAlbums/{album.StringId}/photos";
169170

170171
// Act
171172
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
@@ -180,7 +181,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
180181
responseDocument.Links.Prev.Should().BeNull();
181182
responseDocument.Links.Next.Should().BeNull();
182183

183-
string photoLink = $"{HostPrefix}/photos/{album.Photos.ElementAt(0).StringId}";
184+
string photoLink = $"{HostPrefix}{PathPrefix}/photos/{album.Photos.ElementAt(0).StringId}";
184185

185186
responseDocument.Data.ManyValue.ShouldHaveCount(1);
186187
responseDocument.Data.ManyValue[0].Links.Self.Should().Be(photoLink);
@@ -201,7 +202,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
201202
await dbContext.SaveChangesAsync();
202203
});
203204

204-
string route = $"/photos/{photo.StringId}/relationships/album";
205+
string route = $"{PathPrefix}/photos/{photo.StringId}/relationships/album";
205206

206207
// Act
207208
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
@@ -210,7 +211,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
210211
httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);
211212

212213
responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}");
213-
responseDocument.Links.Related.Should().Be($"{HostPrefix}/photos/{photo.StringId}/album");
214+
responseDocument.Links.Related.Should().Be($"{HostPrefix}{PathPrefix}/photos/{photo.StringId}/album");
214215
responseDocument.Links.First.Should().BeNull();
215216
responseDocument.Links.Last.Should().BeNull();
216217
responseDocument.Links.Prev.Should().BeNull();
@@ -234,7 +235,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
234235
await dbContext.SaveChangesAsync();
235236
});
236237

237-
string route = $"/photoAlbums/{album.StringId}/relationships/photos";
238+
string route = $"{PathPrefix}/photoAlbums/{album.StringId}/relationships/photos";
238239

239240
// Act
240241
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
@@ -243,7 +244,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
243244
httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);
244245

245246
responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}");
246-
responseDocument.Links.Related.Should().Be($"{HostPrefix}/photoAlbums/{album.StringId}/photos");
247+
responseDocument.Links.Related.Should().Be($"{HostPrefix}{PathPrefix}/photoAlbums/{album.StringId}/photos");
247248
responseDocument.Links.First.Should().Be($"{HostPrefix}{route}");
248249
responseDocument.Links.Last.Should().BeNull();
249250
responseDocument.Links.Prev.Should().BeNull();
@@ -288,7 +289,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
288289
}
289290
};
290291

291-
const string route = "/photoAlbums?include=photos";
292+
string route = $"{PathPrefix}/photoAlbums?include=photos";
292293

293294
// Act
294295
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecutePostAsync<Document>(route, requestBody);
@@ -303,13 +304,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
303304
responseDocument.Links.Prev.Should().BeNull();
304305
responseDocument.Links.Next.Should().BeNull();
305306

306-
string albumLink = $"{HostPrefix}/photoAlbums/{responseDocument.Data.SingleValue.Id}";
307+
string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{responseDocument.Data.SingleValue.Id}";
307308

308309
responseDocument.Data.SingleValue.Links.Self.Should().Be(albumLink);
309310
responseDocument.Data.SingleValue.Relationships["photos"].Links.Self.Should().Be($"{albumLink}/relationships/photos");
310311
responseDocument.Data.SingleValue.Relationships["photos"].Links.Related.Should().Be($"{albumLink}/photos");
311312

312-
string photoLink = $"{HostPrefix}/photos/{existingPhoto.StringId}";
313+
string photoLink = $"{HostPrefix}{PathPrefix}/photos/{existingPhoto.StringId}";
313314

314315
responseDocument.Included.ShouldHaveCount(1);
315316
responseDocument.Included[0].Links.Self.Should().Be(photoLink);
@@ -350,7 +351,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
350351
}
351352
};
352353

353-
string route = $"/photos/{existingPhoto.StringId}?include=album";
354+
string route = $"{PathPrefix}/photos/{existingPhoto.StringId}?include=album";
354355

355356
// Act
356357
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecutePatchAsync<Document>(route, requestBody);
@@ -365,14 +366,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
365366
responseDocument.Links.Prev.Should().BeNull();
366367
responseDocument.Links.Next.Should().BeNull();
367368

368-
string photoLink = $"{HostPrefix}/photos/{existingPhoto.StringId}";
369+
string photoLink = $"{HostPrefix}{PathPrefix}/photos/{existingPhoto.StringId}";
369370

370371
responseDocument.Data.SingleValue.ShouldNotBeNull();
371372
responseDocument.Data.SingleValue.Links.Self.Should().Be(photoLink);
372373
responseDocument.Data.SingleValue.Relationships["album"].Links.Self.Should().Be($"{photoLink}/relationships/album");
373374
responseDocument.Data.SingleValue.Relationships["album"].Links.Related.Should().Be($"{photoLink}/album");
374375

375-
string albumLink = $"{HostPrefix}/photoAlbums/{existingAlbum.StringId}";
376+
string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{existingAlbum.StringId}";
376377

377378
responseDocument.Included.ShouldHaveCount(1);
378379
responseDocument.Included[0].Links.Self.Should().Be(albumLink);

0 commit comments

Comments
 (0)