@@ -12,7 +12,6 @@ namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.M
12
12
13
13
public sealed class CreateResourceTests : BaseOpenApiClientTests
14
14
{
15
- private const string DataPropertyName = "Data" ;
16
15
private readonly NrtOffMsvOffFakers _fakers = new ( ) ;
17
16
18
17
[ Theory ]
@@ -38,7 +37,7 @@ public async Task Can_clear_attribute(string attributePropertyName, string jsonP
38
37
}
39
38
} ;
40
39
41
- requestDocument . Data . Attributes . SetPropertyValue ( attributePropertyName , null ) ;
40
+ SetPropertyToDefaultValue ( requestDocument . Data . Attributes , attributePropertyName ) ;
42
41
43
42
using var wrapper = FakeHttpClientWrapper . Create ( HttpStatusCode . NoContent , null ) ;
44
43
var apiClient = new NrtOffMsvOffClient ( wrapper . HttpClient ) ;
@@ -81,8 +80,7 @@ public async Task Can_set_attribute_to_default_value(string attributePropertyNam
81
80
}
82
81
} ;
83
82
84
- object ? defaultValue = requestDocument . Data . Attributes . GetDefaultValueForProperty ( attributePropertyName ) ;
85
- requestDocument . Data . Attributes . SetPropertyValue ( attributePropertyName , defaultValue ) ;
83
+ SetPropertyToDefaultValue ( requestDocument . Data . Attributes , attributePropertyName ) ;
86
84
87
85
using var wrapper = FakeHttpClientWrapper . Create ( HttpStatusCode . NoContent , null ) ;
88
86
var apiClient = new NrtOffMsvOffClient ( wrapper . HttpClient ) ;
@@ -108,7 +106,7 @@ public async Task Can_set_attribute_to_default_value(string attributePropertyNam
108
106
[ InlineData ( nameof ( ResourceAttributesInPostRequest . ReferenceType ) , "referenceType" ) ]
109
107
[ InlineData ( nameof ( ResourceAttributesInPostRequest . ValueType ) , "valueType" ) ]
110
108
[ InlineData ( nameof ( ResourceAttributesInPostRequest . NullableValueType ) , "nullableValueType" ) ]
111
- public async Task Can_exclude_attribute ( string attributePropertyName , string jsonPropertyName )
109
+ public async Task Can_omit_attribute ( string attributePropertyName , string jsonPropertyName )
112
110
{
113
111
// Arrange
114
112
var requestDocument = new ResourcePostRequestDocument
@@ -126,9 +124,7 @@ public async Task Can_exclude_attribute(string attributePropertyName, string jso
126
124
}
127
125
} ;
128
126
129
- ResourceAttributesInPostRequest emptyAttributesObject = new ( ) ;
130
- object ? defaultValue = emptyAttributesObject . GetPropertyValue ( attributePropertyName ) ;
131
- requestDocument . Data . Attributes . SetPropertyValue ( attributePropertyName , defaultValue ) ;
127
+ SetPropertyToInitialValue ( requestDocument . Data . Attributes , attributePropertyName ) ;
132
128
133
129
using var wrapper = FakeHttpClientWrapper . Create ( HttpStatusCode . NoContent , null ) ;
134
130
var apiClient = new NrtOffMsvOffClient ( wrapper . HttpClient ) ;
@@ -151,7 +147,7 @@ public async Task Can_exclude_attribute(string attributePropertyName, string jso
151
147
[ InlineData ( nameof ( ResourceAttributesInPostRequest . RequiredReferenceType ) , "requiredReferenceType" ) ]
152
148
[ InlineData ( nameof ( ResourceAttributesInPostRequest . RequiredValueType ) , "requiredValueType" ) ]
153
149
[ InlineData ( nameof ( ResourceAttributesInPostRequest . RequiredNullableValueType ) , "requiredNullableValueType" ) ]
154
- public async Task Cannot_exclude_attribute ( string attributePropertyName , string jsonPropertyName )
150
+ public async Task Cannot_omit_attribute ( string attributePropertyName , string jsonPropertyName )
155
151
{
156
152
// Arrange
157
153
var requestDocument = new ResourcePostRequestDocument
@@ -169,9 +165,7 @@ public async Task Cannot_exclude_attribute(string attributePropertyName, string
169
165
}
170
166
} ;
171
167
172
- ResourceAttributesInPostRequest emptyAttributesObject = new ( ) ;
173
- object ? defaultValue = emptyAttributesObject . GetPropertyValue ( attributePropertyName ) ;
174
- requestDocument . Data . Attributes . SetPropertyValue ( attributePropertyName , defaultValue ) ;
168
+ SetPropertyToInitialValue ( requestDocument . Data . Attributes , attributePropertyName ) ;
175
169
176
170
using var wrapper = FakeHttpClientWrapper . Create ( HttpStatusCode . NoContent , null ) ;
177
171
var apiClient = new NrtOffMsvOffClient ( wrapper . HttpClient ) ;
@@ -210,8 +204,7 @@ public async Task Can_clear_relationship_with_partial_attribute_serialization(st
210
204
}
211
205
} ;
212
206
213
- object ? relationshipObject = requestDocument . Data . Relationships . GetPropertyValue ( relationshipPropertyName ) ;
214
- relationshipObject ! . SetPropertyValue ( DataPropertyName , null ) ;
207
+ SetDataPropertyToNull ( requestDocument . Data . Relationships , relationshipPropertyName ) ;
215
208
216
209
using var wrapper = FakeHttpClientWrapper . Create ( HttpStatusCode . NoContent , null ) ;
217
210
var apiClient = new NrtOffMsvOffClient ( wrapper . HttpClient ) ;
@@ -251,8 +244,7 @@ public async Task Can_clear_relationship_without_partial_attribute_serialization
251
244
}
252
245
} ;
253
246
254
- object ? relationshipObject = requestDocument . Data . Relationships . GetPropertyValue ( relationshipPropertyName ) ;
255
- relationshipObject ! . SetPropertyValue ( DataPropertyName , null ) ;
247
+ SetDataPropertyToNull ( requestDocument . Data . Relationships , relationshipPropertyName ) ;
256
248
257
249
using var wrapper = FakeHttpClientWrapper . Create ( HttpStatusCode . NoContent , null ) ;
258
250
var apiClient = new NrtOffMsvOffClient ( wrapper . HttpClient ) ;
@@ -290,8 +282,7 @@ public async Task Cannot_clear_relationship_with_partial_attribute_serialization
290
282
}
291
283
} ;
292
284
293
- object ? relationshipObject = requestDocument . Data . Relationships . GetPropertyValue ( relationshipPropertyName ) ;
294
- relationshipObject ! . SetPropertyValue ( DataPropertyName , null ) ;
285
+ SetDataPropertyToNull ( requestDocument . Data . Relationships , relationshipPropertyName ) ;
295
286
296
287
using var wrapper = FakeHttpClientWrapper . Create ( HttpStatusCode . NoContent , null ) ;
297
288
var apiClient = new NrtOffMsvOffClient ( wrapper . HttpClient ) ;
@@ -330,8 +321,7 @@ public async Task Cannot_clear_relationship_without_partial_attribute_serializat
330
321
}
331
322
} ;
332
323
333
- object ? relationshipObject = requestDocument . Data . Relationships . GetPropertyValue ( relationshipPropertyName ) ;
334
- relationshipObject ! . SetPropertyValue ( DataPropertyName , null ) ;
324
+ SetDataPropertyToNull ( requestDocument . Data . Relationships , relationshipPropertyName ) ;
335
325
336
326
using var wrapper = FakeHttpClientWrapper . Create ( HttpStatusCode . NoContent , null ) ;
337
327
var apiClient = new NrtOffMsvOffClient ( wrapper . HttpClient ) ;
@@ -350,7 +340,7 @@ public async Task Cannot_clear_relationship_without_partial_attribute_serializat
350
340
[ Theory ]
351
341
[ InlineData ( nameof ( ResourceRelationshipsInPostRequest . ToOne ) , "toOne" ) ]
352
342
[ InlineData ( nameof ( ResourceRelationshipsInPostRequest . ToMany ) , "toMany" ) ]
353
- public async Task Can_exclude_relationship_with_partial_attribute_serialization ( string relationshipPropertyName , string jsonPropertyName )
343
+ public async Task Can_omit_relationship_with_partial_attribute_serialization ( string relationshipPropertyName , string jsonPropertyName )
354
344
{
355
345
// Arrange
356
346
var requestDocument = new ResourcePostRequestDocument
@@ -368,9 +358,7 @@ public async Task Can_exclude_relationship_with_partial_attribute_serialization(
368
358
}
369
359
} ;
370
360
371
- ResourceRelationshipsInPostRequest emptyRelationshipsObject = new ( ) ;
372
- object ? defaultValue = emptyRelationshipsObject . GetPropertyValue ( relationshipPropertyName ) ;
373
- requestDocument . Data . Relationships . SetPropertyValue ( relationshipPropertyName , defaultValue ) ;
361
+ SetPropertyToInitialValue ( requestDocument . Data . Relationships , relationshipPropertyName ) ;
374
362
375
363
using var wrapper = FakeHttpClientWrapper . Create ( HttpStatusCode . NoContent , null ) ;
376
364
var apiClient = new NrtOffMsvOffClient ( wrapper . HttpClient ) ;
@@ -392,7 +380,7 @@ public async Task Can_exclude_relationship_with_partial_attribute_serialization(
392
380
[ Theory ]
393
381
[ InlineData ( nameof ( ResourceRelationshipsInPostRequest . ToOne ) , "toOne" ) ]
394
382
[ InlineData ( nameof ( ResourceRelationshipsInPostRequest . ToMany ) , "toMany" ) ]
395
- public async Task Can_exclude_relationship_without_partial_attribute_serialization ( string relationshipPropertyName , string jsonPropertyName )
383
+ public async Task Can_omit_relationship_without_partial_attribute_serialization ( string relationshipPropertyName , string jsonPropertyName )
396
384
{
397
385
// Arrange
398
386
var requestDocument = new ResourcePostRequestDocument
@@ -410,9 +398,7 @@ public async Task Can_exclude_relationship_without_partial_attribute_serializati
410
398
}
411
399
} ;
412
400
413
- ResourceRelationshipsInPostRequest emptyRelationshipsObject = new ( ) ;
414
- object ? defaultValue = emptyRelationshipsObject . GetPropertyValue ( relationshipPropertyName ) ;
415
- requestDocument . Data . Relationships . SetPropertyValue ( relationshipPropertyName , defaultValue ) ;
401
+ SetPropertyToInitialValue ( requestDocument . Data . Relationships , relationshipPropertyName ) ;
416
402
417
403
using var wrapper = FakeHttpClientWrapper . Create ( HttpStatusCode . NoContent , null ) ;
418
404
var apiClient = new NrtOffMsvOffClient ( wrapper . HttpClient ) ;
0 commit comments