1515using Xunit ;
1616using JsonApiDotNetCore . Services ;
1717using JsonApiDotNetCore . Serialization ;
18+ using System . Linq ;
1819
1920namespace JsonApiDotNetCoreExampleTests . Acceptance
2021{
@@ -366,5 +367,35 @@ public async Task Can_Patch_TodoItem()
366367 Assert . Equal ( newTodoItem . Description , deserializedBody . Description ) ;
367368 Assert . Equal ( newTodoItem . Ordinal , deserializedBody . Ordinal ) ;
368369 }
370+
371+ [ Fact ]
372+ public async Task Can_Delete_TodoItem ( )
373+ {
374+ // Arrange
375+ var person = new Person ( ) ;
376+ _context . People . Add ( person ) ;
377+ _context . SaveChanges ( ) ;
378+
379+ var todoItem = _todoItemFaker . Generate ( ) ;
380+ todoItem . Owner = person ;
381+ _context . TodoItems . Add ( todoItem ) ;
382+ _context . SaveChanges ( ) ;
383+
384+ var httpMethod = new HttpMethod ( "DELETE" ) ;
385+ var route = $ "/api/v1/todo-items/{ todoItem . Id } ";
386+
387+ var request = new HttpRequestMessage ( httpMethod , route ) ;
388+ request . Content = new StringContent ( string . Empty ) ;
389+ request . Content . Headers . ContentType = new MediaTypeHeaderValue ( "application/vnd.api+json" ) ;
390+
391+ var description = new RequestProperties ( "Delete TodoItem" ) ;
392+
393+ // Act
394+ var response = await _fixture . MakeRequest < TodoItem > ( description , request ) ;
395+
396+ // Assert
397+ Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
398+ Assert . Null ( _context . TodoItems . FirstOrDefault ( t => t . Id == todoItem . Id ) ) ;
399+ }
369400 }
370401}
0 commit comments