@@ -318,5 +318,53 @@ public async Task Can_Post_TodoItem()
318
318
Assert . Equal ( HttpStatusCode . Created , response . StatusCode ) ;
319
319
Assert . Equal ( todoItem . Description , deserializedBody . Description ) ;
320
320
}
321
+
322
+ [ Fact ]
323
+ public async Task Can_Patch_TodoItem ( )
324
+ {
325
+ // Arrange
326
+ var person = new Person ( ) ;
327
+ _context . People . Add ( person ) ;
328
+ _context . SaveChanges ( ) ;
329
+
330
+ var todoItem = _todoItemFaker . Generate ( ) ;
331
+ todoItem . Owner = person ;
332
+ _context . TodoItems . Add ( todoItem ) ;
333
+ _context . SaveChanges ( ) ;
334
+
335
+ var newTodoItem = _todoItemFaker . Generate ( ) ;
336
+
337
+ var content = new
338
+ {
339
+ data = new
340
+ {
341
+ type = "todo-items" ,
342
+ attributes = new
343
+ {
344
+ description = newTodoItem . Description ,
345
+ ordinial = newTodoItem . Ordinal
346
+ }
347
+ }
348
+ } ;
349
+
350
+ var httpMethod = new HttpMethod ( "PATCH" ) ;
351
+ var route = $ "/api/v1/todo-items/{ todoItem . Id } ";
352
+
353
+ var request = new HttpRequestMessage ( httpMethod , route ) ;
354
+ request . Content = new StringContent ( JsonConvert . SerializeObject ( content ) ) ;
355
+ request . Content . Headers . ContentType = new MediaTypeHeaderValue ( "application/vnd.api+json" ) ;
356
+
357
+ var description = new RequestProperties ( "Patch TodoItem" ) ;
358
+
359
+ // Act
360
+ var response = await _fixture . MakeRequest < TodoItem > ( description , request ) ;
361
+ var body = await response . Content . ReadAsStringAsync ( ) ;
362
+ var deserializedBody = ( TodoItem ) JsonApiDeSerializer . Deserialize ( body , _jsonApiContext ) ;
363
+
364
+ // Assert
365
+ Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
366
+ Assert . Equal ( newTodoItem . Description , deserializedBody . Description ) ;
367
+ Assert . Equal ( newTodoItem . Ordinal , deserializedBody . Ordinal ) ;
368
+ }
321
369
}
322
370
}
0 commit comments