Skip to content

Commit 845d4ad

Browse files
Pushed updates addressing missing review comments.
1 parent 2cb2e37 commit 845d4ad

File tree

2 files changed

+42
-58
lines changed

2 files changed

+42
-58
lines changed

test/JsonApiDotNetCoreTests/IntegrationTests/Meta/OperationsRequestMetaTests.cs

Lines changed: 30 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ public OperationsRequestMetaTests(IntegrationTestContext<TestableStartup<MetaDbC
3838
}
3939

4040
[Fact]
41-
public async Task Accepts_meta_in_update_resource_operation_with_ToOne_relationship_operation()
41+
public async Task Accepts_meta_in_update_resource_operation_with_ToOne_relationship()
4242
{
4343
// Arrange
4444
var store = _testContext.Factory.Services.GetRequiredService<RequestDocumentStore>();
4545

4646
Dictionary<string, object?> documentMeta = _fakers.DocumentMeta.GenerateOne();
4747
Dictionary<string, object?> operationMeta = _fakers.OperationMeta.GenerateOne();
48-
Dictionary<string, object?> relationshipMeta = _fakers.RelationshipMeta.GenerateOne();
4948
Dictionary<string, object?> resourceMeta = _fakers.ResourceMeta.GenerateOne();
49+
Dictionary<string, object?> relationshipMeta = _fakers.RelationshipMeta.GenerateOne();
5050
Dictionary<string, object?> identifierMeta = _fakers.IdentifierMeta.GenerateOne();
5151

5252
SupportTicket existingTicket = _fakers.SupportTicket.GenerateOne();
@@ -107,16 +107,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
107107

108108
store.Document.Meta.Should().BeEquivalentToJson(documentMeta);
109109

110-
store.Document.Operations.Should().HaveCount(1);
111-
112110
store.Document.Operations.Should().ContainSingle().Which.With(operation =>
113111
{
114112
operation.Should().NotBeNull();
115113

116114
operation.Meta.Should().BeEquivalentToJson(operationMeta);
117115

118-
operation.Data.Should().NotBeNull();
119-
120116
operation.Data.SingleValue.Should().NotBeNull();
121117

122118
operation.Data.SingleValue.Meta.Should().BeEquivalentToJson(resourceMeta);
@@ -127,8 +123,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
127123

128124
value.Meta.Should().BeEquivalentToJson(relationshipMeta);
129125

130-
value.Data.Should().NotBeNull();
131-
132126
value.Data.SingleValue.Should().NotBeNull();
133127

134128
value.Data.SingleValue.Meta.Should().BeEquivalentToJson(identifierMeta);
@@ -137,14 +131,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
137131
}
138132

139133
[Fact]
140-
public async Task Accepts_meta_in_update_resource_operation_with_ToMany_relationship_operation()
134+
public async Task Accepts_meta_in_update_resource_operation_with_ToMany_relationship()
141135
{
142136
// Arrange
143137
var store = _testContext.Factory.Services.GetRequiredService<RequestDocumentStore>();
144138

145139
Dictionary<string, object?> documentMeta = _fakers.DocumentMeta.GenerateOne();
146-
Dictionary<string, object?> resourceMeta = _fakers.ResourceMeta.GenerateOne();
147140
Dictionary<string, object?> operationMeta = _fakers.OperationMeta.GenerateOne();
141+
Dictionary<string, object?> resourceMeta = _fakers.ResourceMeta.GenerateOne();
148142
Dictionary<string, object?> relationshipMeta = _fakers.RelationshipMeta.GenerateOne();
149143
Dictionary<string, object?> identifierMeta1 = _fakers.IdentifierMeta.GenerateOne();
150144
Dictionary<string, object?> identifierMeta2 = _fakers.IdentifierMeta.GenerateOne();
@@ -229,17 +223,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
229223

230224
operation.Data.SingleValue.Meta.Should().BeEquivalentToJson(resourceMeta);
231225

232-
operation.Data.SingleValue.Relationships.Should().NotBeNull();
233-
234226
operation.Data.SingleValue.Relationships.Should().ContainKey("tickets").WhoseValue.With(value =>
235227
{
236228
value.Should().NotBeNull();
237229

238230
value.Meta.Should().BeEquivalentToJson(relationshipMeta);
239231

240-
value.Data.Should().NotBeNull();
241-
242-
value.Data.ManyValue.Should().NotBeNull();
243232
value.Data.ManyValue.Should().HaveCount(2);
244233

245234
value.Data.ManyValue[0].Meta.Should().BeEquivalentToJson(identifierMeta1);
@@ -249,7 +238,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
249238
}
250239

251240
[Fact]
252-
public async Task Accepts_meta_in_add_resource_request_with_ToOne_relationship_operation()
241+
public async Task Accepts_meta_in_add_resource_operation_with_ToOne_relationship()
253242
{
254243
// Arrange
255244
var store = _testContext.Factory.Services.GetRequiredService<RequestDocumentStore>();
@@ -314,18 +303,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
314303

315304
store.Document.Should().NotBeNull();
316305

317-
store.Document.Meta.Should().HaveCount(documentMeta.Count);
318306
store.Document.Meta.Should().BeEquivalentToJson(documentMeta);
319307

320-
store.Document.Operations.Should().NotBeNull();
321-
322308
store.Document.Operations.Should().ContainSingle().Which.With(operation =>
323309
{
324310
operation.Should().NotBeNull();
325311

326312
operation.Meta.Should().BeEquivalentToJson(operationMeta);
327313

328-
operation.Data.Should().NotBeNull();
329314
operation.Data.SingleValue.Should().NotBeNull();
330315

331316
operation.Data.SingleValue.Meta.Should().BeEquivalentToJson(resourceMeta);
@@ -336,8 +321,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
336321

337322
value.Meta.Should().BeEquivalentToJson(relationshipMeta);
338323

339-
value.Data.Should().NotBeNull();
340-
341324
value.Data.SingleValue.Should().NotBeNull();
342325

343326
value.Data.SingleValue.Meta.Should().BeEquivalentToJson(identifierMeta);
@@ -346,15 +329,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
346329
}
347330

348331
[Fact]
349-
public async Task Accepts_meta_in_add_resource_request_with_ToMany_relationship_operation()
332+
public async Task Accepts_meta_in_add_resource_operation_with_ToMany_relationship()
350333
{
351334
// Arrange
352335
var store = _testContext.Factory.Services.GetRequiredService<RequestDocumentStore>();
353336

354337
Dictionary<string, object?> documentMeta = _fakers.DocumentMeta.GenerateOne();
355338
Dictionary<string, object?> operationMeta = _fakers.OperationMeta.GenerateOne();
356-
Dictionary<string, object?> relationshipMeta = _fakers.RelationshipMeta.GenerateOne();
357339
Dictionary<string, object?> resourceMeta = _fakers.ResourceMeta.GenerateOne();
340+
Dictionary<string, object?> relationshipMeta = _fakers.RelationshipMeta.GenerateOne();
358341
Dictionary<string, object?> identifierMeta1 = _fakers.IdentifierMeta.GenerateOne();
359342
Dictionary<string, object?> identifierMeta2 = _fakers.IdentifierMeta.GenerateOne();
360343

@@ -425,14 +408,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
425408

426409
store.Document.Meta.Should().BeEquivalentToJson(documentMeta);
427410

428-
store.Document.Operations.Should().NotBeNull();
429-
430411
store.Document.Operations.Should().ContainSingle().Which.With(operation =>
431412
{
432413
operation.Should().NotBeNull();
433414

434415
operation.Meta.Should().BeEquivalentToJson(operationMeta);
435-
operation.Data.Should().NotBeNull();
436416

437417
operation.Data.SingleValue.Should().NotBeNull();
438418

@@ -444,9 +424,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
444424

445425
value.Meta.Should().BeEquivalentToJson(relationshipMeta);
446426

447-
value.Data.Should().NotBeNull();
448-
449-
value.Data.ManyValue.Should().NotBeNull();
450427
value.Data.ManyValue.Should().HaveCount(2);
451428

452429
value.Data.ManyValue[0].Meta.Should().BeEquivalentToJson(identifierMeta1);
@@ -456,7 +433,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
456433
}
457434

458435
[Fact]
459-
public async Task Accepts_meta_in_update_ToOne_relationship_operation()
436+
public async Task Accepts_meta_in_update_operation_ToOne_relationship()
460437
{
461438
// Arrange
462439
var store = _testContext.Factory.Services.GetRequiredService<RequestDocumentStore>();
@@ -512,8 +489,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
512489

513490
store.Document.Meta.Should().BeEquivalentToJson(documentMeta);
514491

515-
store.Document.Operations.Should().NotBeNull();
516-
517492
store.Document.Operations.Should().ContainSingle().Which.With(operation =>
518493
{
519494
operation.Should().NotBeNull();
@@ -526,7 +501,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
526501
}
527502

528503
[Fact]
529-
public async Task Accepts_meta_in_update_ToMany_relationship_operation()
504+
public async Task Accepts_meta_in_update_operation_ToMany_relationship()
530505
{
531506
// Arrange
532507
var store = _testContext.Factory.Services.GetRequiredService<RequestDocumentStore>();
@@ -593,15 +568,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
593568

594569
store.Document.Meta.Should().BeEquivalentToJson(documentMeta);
595570

596-
store.Document.Operations.Should().NotBeNull();
597-
598571
store.Document.Operations.Should().ContainSingle().Which.With(operation =>
599572
{
600573
operation.Should().NotBeNull();
601574

602575
operation.Meta.Should().BeEquivalentToJson(operationMeta);
603576

604-
operation.Data.ManyValue.Should().NotBeNull();
605577
operation.Data.ManyValue.Should().HaveCount(2);
606578

607579
operation.Data.ManyValue[0].Meta.Should().BeEquivalentToJson(identifierMeta1);
@@ -611,7 +583,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
611583
}
612584

613585
[Fact]
614-
public async Task Accepts_meta_in_add_ToMany_relationship_operation()
586+
public async Task Accepts_meta_in_add_operation_ToMany_relationship()
615587
{
616588
// Arrange
617589
var store = _testContext.Factory.Services.GetRequiredService<RequestDocumentStore>();
@@ -678,15 +650,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
678650

679651
store.Document.Meta.Should().BeEquivalentToJson(documentMeta);
680652

681-
store.Document.Operations.Should().NotBeNull();
682-
683653
store.Document.Operations.Should().ContainSingle().Which.With(operation =>
684654
{
685655
operation.Should().NotBeNull();
686656

687657
operation.Meta.Should().BeEquivalentToJson(operationMeta);
688658

689-
operation.Data.ManyValue.Should().NotBeNull();
690659
operation.Data.ManyValue.Should().HaveCount(2);
691660

692661
operation.Data.ManyValue[0].Meta.Should().BeEquivalentToJson(identifierMeta1);
@@ -696,23 +665,26 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
696665
}
697666

698667
[Fact]
699-
public async Task Accepts_meta_in_remove_from_ToOne_relationship_operation()
668+
public async Task Accepts_meta_in_remove_operation_from_ToMany_relationship()
700669
{
701670
// Arrange
702671
var store = _testContext.Factory.Services.GetRequiredService<RequestDocumentStore>();
703672

704673
Dictionary<string, object?> documentMeta = _fakers.DocumentMeta.GenerateOne();
705674
Dictionary<string, object?> operationMeta = _fakers.OperationMeta.GenerateOne();
706-
Dictionary<string, object?> identifierMeta = _fakers.IdentifierMeta.GenerateOne();
675+
Dictionary<string, object?> identifierMeta1 = _fakers.IdentifierMeta.GenerateOne();
676+
Dictionary<string, object?> identifierMeta2 = _fakers.IdentifierMeta.GenerateOne();
707677

708678
ProductFamily existingFamily = _fakers.ProductFamily.GenerateOne();
709-
SupportTicket existingTicket = _fakers.SupportTicket.GenerateOne();
679+
SupportTicket existingTicket1 = _fakers.SupportTicket.GenerateOne();
680+
existingTicket1.ProductFamily = existingFamily;
681+
SupportTicket existingTicket2 = _fakers.SupportTicket.GenerateOne();
682+
existingTicket2.ProductFamily = existingFamily;
710683

711684
await _testContext.RunOnDatabaseAsync(async dbContext =>
712685
{
713686
dbContext.ProductFamilies.Add(existingFamily);
714-
existingTicket.ProductFamily = existingFamily;
715-
dbContext.SupportTickets.Add(existingTicket);
687+
dbContext.SupportTickets.AddRange(existingTicket1, existingTicket2);
716688
await dbContext.SaveChangesAsync();
717689
});
718690

@@ -734,8 +706,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
734706
new
735707
{
736708
type = "supportTickets",
737-
id = existingTicket.StringId,
738-
meta = identifierMeta
709+
id = existingTicket1.StringId,
710+
meta = identifierMeta1
711+
},
712+
new
713+
{
714+
type = "supportTickets",
715+
id = existingTicket2.StringId,
716+
meta = identifierMeta2
739717
}
740718
},
741719
meta = operationMeta
@@ -756,23 +734,21 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
756734

757735
store.Document.Meta.Should().BeEquivalentToJson(documentMeta);
758736

759-
store.Document.Operations.Should().NotBeNull();
760-
761737
store.Document.Operations.Should().ContainSingle().Which.With(operation =>
762738
{
763739
operation.Should().NotBeNull();
764740

765741
operation.Meta.Should().BeEquivalentToJson(operationMeta);
766742

767-
operation.Data.ManyValue.Should().NotBeNull();
768-
operation.Data.ManyValue.Should().HaveCount(1);
743+
operation.Data.ManyValue.Should().HaveCount(2);
769744

770-
operation.Data.ManyValue[0].Meta.Should().BeEquivalentToJson(identifierMeta);
745+
operation.Data.ManyValue[0].Meta.Should().BeEquivalentToJson(identifierMeta1);
746+
operation.Data.ManyValue[1].Meta.Should().BeEquivalentToJson(identifierMeta2);
771747
});
772748
}
773749

774750
[Fact]
775-
public async Task Accepts_meta_in_atomic_remove_resource_operation()
751+
public async Task Accepts_meta_in_remove_resource_operation()
776752
{
777753
// Arrange
778754
var store = _testContext.Factory.Services.GetRequiredService<RequestDocumentStore>();
@@ -820,8 +796,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
820796

821797
store.Document.Meta.Should().BeEquivalentToJson(documentMeta);
822798

823-
store.Document.Operations.Should().HaveCount(1);
824-
825799
store.Document.Operations.Should().ContainSingle().Which.With(operation =>
826800
{
827801
operation.Should().NotBeNull();

test/JsonApiDotNetCoreTests/IntegrationTests/Meta/RequestMetaTests.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public async Task Accepts_meta_in_update_resource_request_with_ToOne_relationshi
4949
Dictionary<string, object?> identifierMeta = _fakers.IdentifierMeta.GenerateOne();
5050

5151
SupportTicket existingTicket = _fakers.SupportTicket.GenerateOne();
52+
string newTicketDescription = _fakers.SupportTicket.GenerateOne().Description;
5253
ProductFamily existingFamily = _fakers.ProductFamily.GenerateOne();
5354

5455
await _testContext.RunOnDatabaseAsync(async dbContext =>
@@ -64,6 +65,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
6465
{
6566
type = "supportTickets",
6667
id = existingTicket.StringId,
68+
attributes = new
69+
{
70+
description = newTicketDescription
71+
},
6772
relationships = new
6873
{
6974
productFamily = new
@@ -120,6 +125,7 @@ public async Task Accepts_meta_in_update_resource_request_with_ToMany_relationsh
120125
Dictionary<string, object?> identifierMeta2 = _fakers.IdentifierMeta.GenerateOne();
121126

122127
ProductFamily existingFamily = _fakers.ProductFamily.GenerateOne();
128+
string newFamilyName = _fakers.ProductFamily.GenerateOne().Name;
123129
SupportTicket existingTicket1 = _fakers.SupportTicket.GenerateOne();
124130
SupportTicket existingTicket2 = _fakers.SupportTicket.GenerateOne();
125131

@@ -136,6 +142,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
136142
{
137143
type = "productFamilies",
138144
id = existingFamily.StringId,
145+
attributes = new
146+
{
147+
name = newFamilyName
148+
},
139149
relationships = new
140150
{
141151
tickets = new
@@ -415,9 +425,9 @@ public async Task Accepts_meta_in_update_ToMany_relationship_request()
415425
Dictionary<string, object?> identifierMeta1 = _fakers.IdentifierMeta.GenerateOne();
416426
Dictionary<string, object?> identifierMeta2 = _fakers.IdentifierMeta.GenerateOne();
417427

428+
ProductFamily existingFamily = _fakers.ProductFamily.GenerateOne();
418429
SupportTicket existingTicket1 = _fakers.SupportTicket.GenerateOne();
419430
SupportTicket existingTicket2 = _fakers.SupportTicket.GenerateOne();
420-
ProductFamily existingFamily = _fakers.ProductFamily.GenerateOne();
421431

422432
await _testContext.RunOnDatabaseAsync(async dbContext =>
423433
{
@@ -466,7 +476,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
466476
}
467477

468478
[Fact]
469-
public async Task Accepts_meta_in_add_ToMany_relationship_request()
479+
public async Task Accepts_meta_in_add_to_ToMany_relationship_request()
470480
{
471481
// Arrange
472482
var store = _testContext.Factory.Services.GetRequiredService<RequestDocumentStore>();

0 commit comments

Comments
 (0)