11using System . Net ;
2- using System . Text . Json ;
32using FluentAssertions ;
43using JsonApiDotNetCore . Serialization . Objects ;
54using JsonApiDotNetCore . Serialization . Request . Adapters ;
@@ -47,6 +46,7 @@ public async Task Accepts_meta_in_update_resource_request_with_to_one_relationsh
4746 var documentMeta = _fakers . DocumentMeta . GenerateOne ( ) ;
4847 var resourceMeta = _fakers . ResourceMeta . GenerateOne ( ) ;
4948 var relationshipMeta = _fakers . RelationshipMeta . GenerateOne ( ) ;
49+ var identifierMeta = _fakers . RelationshipIdentifierMeta . GenerateOne ( ) ;
5050
5151 SupportTicket existingTicket = _fakers . SupportTicket . GenerateOne ( ) ;
5252 ProductFamily existingFamily = _fakers . ProductFamily . GenerateOne ( ) ;
@@ -71,7 +71,8 @@ await _testContext.RunOnDatabaseAsync(async dbContex =>
7171 data = new
7272 {
7373 type = "productFamilies" ,
74- id = existingFamily . StringId
74+ id = existingFamily . StringId ,
75+ meta = identifierMeta
7576 } ,
7677 meta = relationshipMeta
7778 }
@@ -103,6 +104,8 @@ await _testContext.RunOnDatabaseAsync(async dbContex =>
103104 {
104105 value . Should ( ) . NotBeNull ( ) ;
105106 value . Meta . Should ( ) . BeEquivalentToJson ( relationshipMeta ) ;
107+ value . Data . SingleValue . Should ( ) . NotBeNull ( ) ;
108+ value . Data . SingleValue . Meta . Should ( ) . BeEquivalentToJson ( identifierMeta ) ;
106109 } ) ;
107110 }
108111
@@ -197,6 +200,9 @@ public async Task Accepts_meta_in_post_resource_request_with_to_one_relationship
197200 var store = _testContext . Factory . Services . GetRequiredService < RequestDocumentStore > ( ) ;
198201
199202 var documentMeta = _fakers . DocumentMeta . GenerateOne ( ) ;
203+ var resourceMeta = _fakers . ResourceMeta . GenerateOne ( ) ;
204+ var relationshipMeta = _fakers . RelationshipMeta . GenerateOne ( ) ;
205+ var identifierMeta = _fakers . RelationshipIdentifierMeta . GenerateOne ( ) ;
200206
201207 string newTicketDescription = _fakers . SupportTicket . GenerateOne ( ) . Description ;
202208 ProductFamily existingFamily = _fakers . ProductFamily . GenerateOne ( ) ;
@@ -223,10 +229,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
223229 data = new
224230 {
225231 type = "productFamilies" ,
226- id = existingFamily . StringId
227- }
232+ id = existingFamily . StringId ,
233+ meta = identifierMeta
234+ } ,
235+ meta = relationshipMeta
228236 }
229- }
237+ } ,
238+ meta = resourceMeta
230239 } ,
231240 meta = documentMeta
232241 } ;
@@ -243,13 +252,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
243252
244253 store . Document . Meta . Should ( ) . BeEquivalentToJson ( documentMeta ) ;
245254 store . Document . Data . SingleValue . Should ( ) . NotBeNull ( ) ;
255+
256+ store . Document . Data . SingleValue . Meta . Should ( ) . BeEquivalentToJson ( resourceMeta ) ;
257+
246258 store . Document . Data . SingleValue . Relationships . Should ( ) . NotBeNull ( ) ;
247259 store . Document . Data . SingleValue . Relationships . Should ( ) . ContainKey ( "productFamily" ) . WhoseValue . With ( value =>
248260 {
249261 value . Should ( ) . NotBeNull ( ) ;
262+
263+ value . Meta . Should ( ) . BeEquivalentToJson ( relationshipMeta ) ;
264+
250265 value . Data . SingleValue . Should ( ) . NotBeNull ( ) ;
251- value . Data . SingleValue . Type . Should ( ) . Be ( "productFamilies" ) ;
252- value . Data . SingleValue . Id . Should ( ) . Be ( existingFamily . StringId ) ;
266+
267+ value . Data . SingleValue . Meta . Should ( ) . BeEquivalentToJson ( identifierMeta ) ;
253268 } ) ;
254269 }
255270
@@ -261,6 +276,7 @@ public async Task Accepts_meta_in_post_resource_request_with_to_many_relationshi
261276
262277 var documentMeta = _fakers . DocumentMeta . GenerateOne ( ) ;
263278 var resourceMeta = _fakers . ResourceMeta . GenerateOne ( ) ;
279+ var relationshipMeta = _fakers . RelationshipMeta . GenerateOne ( ) ;
264280 var identifierMeta1 = _fakers . RelationshipIdentifierMeta . GenerateOne ( ) ;
265281 var identifierMeta2 = _fakers . RelationshipIdentifierMeta . GenerateOne ( ) ;
266282
@@ -302,7 +318,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
302318 meta = identifierMeta2
303319 }
304320 } ,
305-
321+ meta = relationshipMeta
306322 }
307323 } ,
308324 meta = resourceMeta
@@ -326,10 +342,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
326342 store . Document . Data . SingleValue . Meta . Should ( ) . BeEquivalentToJson ( resourceMeta ) ;
327343
328344 store . Document . Data . SingleValue . Relationships . Should ( ) . NotBeNull ( ) ;
345+
329346 store . Document . Data . SingleValue . Relationships . Should ( ) . ContainKey ( "tickets" ) . WhoseValue . With ( value =>
330347 {
331348 value . Should ( ) . NotBeNull ( ) ;
332349
350+ value . Meta . Should ( ) . BeEquivalentToJson ( relationshipMeta ) ;
351+
333352 value . Data . ManyValue . Should ( ) . HaveCount ( 2 ) ;
334353
335354 value . Data . ManyValue [ 0 ] . Meta . Should ( ) . BeEquivalentToJson ( identifierMeta1 ) ;
0 commit comments