@@ -50,6 +50,7 @@ public async Task Accepts_meta_in_update_resource_operation_with_ToOne_relations
5050 Dictionary < string , object ? > identifierMeta = _fakers . IdentifierMeta . GenerateOne ( ) ;
5151
5252 SupportTicket existingTicket = _fakers . SupportTicket . GenerateOne ( ) ;
53+ string newTicketDescription = _fakers . SupportTicket . GenerateOne ( ) . Description ;
5354 ProductFamily existingFamily = _fakers . ProductFamily . GenerateOne ( ) ;
5455
5556 await _testContext . RunOnDatabaseAsync ( async dbContext =>
@@ -72,7 +73,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
7273 id = existingTicket . StringId ,
7374 attributes = new
7475 {
75- description = existingTicket . Description
76+ description = newTicketDescription
7677 } ,
7778 relationships = new
7879 {
@@ -211,8 +212,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
211212
212213 store . Document . Meta . Should ( ) . BeEquivalentToJson ( documentMeta ) ;
213214
214- store . Document . Operations . Should ( ) . HaveCount ( 1 ) ;
215-
216215 store . Document . Operations . Should ( ) . ContainSingle ( ) . Which . With ( operation =>
217216 {
218217 operation . Should ( ) . NotBeNull ( ) ;
@@ -433,14 +432,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
433432 }
434433
435434 [ Fact ]
436- public async Task Accepts_meta_in_update_operation_ToOne_relationship ( )
435+ public async Task Accepts_meta_in_update_ToOne_relationship_operation ( )
437436 {
438437 // Arrange
439438 var store = _testContext . Factory . Services . GetRequiredService < RequestDocumentStore > ( ) ;
440439
441440 Dictionary < string , object ? > documentMeta = _fakers . DocumentMeta . GenerateOne ( ) ;
442441 Dictionary < string , object ? > operationMeta = _fakers . OperationMeta . GenerateOne ( ) ;
443- Dictionary < string , object ? > relationshipMeta = _fakers . RelationshipMeta . GenerateOne ( ) ;
442+ Dictionary < string , object ? > identifierMeta = _fakers . IdentifierMeta . GenerateOne ( ) ;
444443
445444 SupportTicket existingTicket = _fakers . SupportTicket . GenerateOne ( ) ;
446445 ProductFamily existingFamily = _fakers . ProductFamily . GenerateOne ( ) ;
@@ -469,7 +468,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
469468 {
470469 type = "productFamilies" ,
471470 id = existingFamily . StringId ,
472- meta = relationshipMeta
471+ meta = identifierMeta
473472 } ,
474473 meta = operationMeta
475474 }
@@ -501,7 +500,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
501500 }
502501
503502 [ Fact ]
504- public async Task Accepts_meta_in_update_operation_ToMany_relationship ( )
503+ public async Task Accepts_meta_in_update_ToMany_relationship_operation ( )
505504 {
506505 // Arrange
507506 var store = _testContext . Factory . Services . GetRequiredService < RequestDocumentStore > ( ) ;
@@ -583,7 +582,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
583582 }
584583
585584 [ Fact ]
586- public async Task Accepts_meta_in_add_operation_ToMany_relationship ( )
585+ public async Task Accepts_meta_in_add_ToMany_relationship_operation ( )
587586 {
588587 // Arrange
589588 var store = _testContext . Factory . Services . GetRequiredService < RequestDocumentStore > ( ) ;
@@ -676,15 +675,11 @@ public async Task Accepts_meta_in_remove_operation_from_ToMany_relationship()
676675 Dictionary < string , object ? > identifierMeta2 = _fakers . IdentifierMeta . GenerateOne ( ) ;
677676
678677 ProductFamily existingFamily = _fakers . ProductFamily . GenerateOne ( ) ;
679- SupportTicket existingTicket1 = _fakers . SupportTicket . GenerateOne ( ) ;
680- existingTicket1 . ProductFamily = existingFamily ;
681- SupportTicket existingTicket2 = _fakers . SupportTicket . GenerateOne ( ) ;
682- existingTicket2 . ProductFamily = existingFamily ;
678+ existingFamily . Tickets = _fakers . SupportTicket . GenerateList ( 2 ) ;
683679
684680 await _testContext . RunOnDatabaseAsync ( async dbContext =>
685681 {
686682 dbContext . ProductFamilies . Add ( existingFamily ) ;
687- dbContext . SupportTickets . AddRange ( existingTicket1 , existingTicket2 ) ;
688683 await dbContext . SaveChangesAsync ( ) ;
689684 } ) ;
690685
@@ -706,13 +701,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
706701 new
707702 {
708703 type = "supportTickets" ,
709- id = existingTicket1 . StringId ,
704+ id = existingFamily . Tickets [ 0 ] . StringId ,
710705 meta = identifierMeta1
711706 } ,
712707 new
713708 {
714709 type = "supportTickets" ,
715- id = existingTicket2 . StringId ,
710+ id = existingFamily . Tickets [ 1 ] . StringId ,
716711 meta = identifierMeta2
717712 }
718713 } ,
@@ -790,8 +785,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
790785 // Assert
791786 httpResponse . ShouldHaveStatusCode ( HttpStatusCode . NoContent ) ;
792787
793- responseDocument . Should ( ) . BeEmpty ( ) ;
794-
795788 store . Document . Should ( ) . NotBeNull ( ) ;
796789
797790 store . Document . Meta . Should ( ) . BeEquivalentToJson ( documentMeta ) ;
@@ -803,30 +796,4 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
803796 operation . Meta . Should ( ) . BeEquivalentToJson ( operationMeta ) ;
804797 } ) ;
805798 }
806-
807- private sealed class CapturingDocumentAdapter : IDocumentAdapter
808- {
809- private readonly IDocumentAdapter _innerAdapter ;
810- private readonly RequestDocumentStore _requestDocumentStore ;
811-
812- public CapturingDocumentAdapter ( IDocumentAdapter innerAdapter , RequestDocumentStore requestDocumentStore )
813- {
814- ArgumentNullException . ThrowIfNull ( innerAdapter ) ;
815- ArgumentNullException . ThrowIfNull ( requestDocumentStore ) ;
816-
817- _innerAdapter = innerAdapter ;
818- _requestDocumentStore = requestDocumentStore ;
819- }
820-
821- public object ? Convert ( Document document )
822- {
823- _requestDocumentStore . Document = document ;
824- return _innerAdapter . Convert ( document ) ;
825- }
826- }
827-
828- private sealed class RequestDocumentStore
829- {
830- public Document ? Document { get ; set ; }
831- }
832799}
0 commit comments