@@ -528,7 +528,7 @@ public async Task Can_Update_ToOne_Relationship_ThroughLink()
528
528
}
529
529
530
530
[ Fact ]
531
- public async Task Can_Delete_Relationship_By_Patching_Resource ( )
531
+ public async Task Can_Delete_ToOne_Relationship_By_Patching_Resource ( )
532
532
{
533
533
// arrange
534
534
var person = _personFaker . Generate ( ) ;
@@ -580,6 +580,64 @@ public async Task Can_Delete_Relationship_By_Patching_Resource()
580
580
Assert . Null ( todoItemResult . Owner ) ;
581
581
}
582
582
583
+
584
+ [ Fact ]
585
+ public async Task Can_Delete_ToMany_Relationship_By_Patching_Resource ( )
586
+ {
587
+ // arrange
588
+ var person = _personFaker . Generate ( ) ;
589
+ var todoItem = _todoItemFaker . Generate ( ) ;
590
+ person . TodoItems = new List < TodoItem > ( ) { todoItem } ;
591
+ _context . People . Add ( person ) ;
592
+ _context . SaveChanges ( ) ;
593
+
594
+ var builder = new WebHostBuilder ( )
595
+ . UseStartup < Startup > ( ) ;
596
+
597
+ var server = new TestServer ( builder ) ;
598
+ var client = server . CreateClient ( ) ;
599
+
600
+ var content = new
601
+ {
602
+ data = new
603
+ {
604
+ id = person . Id ,
605
+ type = "people" ,
606
+ relationships = new Dictionary < string , object >
607
+ {
608
+ { "todo-items" , new
609
+ {
610
+ data = new List < object >
611
+ {
612
+
613
+ }
614
+ }
615
+ }
616
+ }
617
+ }
618
+ } ;
619
+
620
+ var httpMethod = new HttpMethod ( "PATCH" ) ;
621
+ var route = $ "/api/v1/people/{ person . Id } ";
622
+ var request = new HttpRequestMessage ( httpMethod , route ) ;
623
+
624
+ string serializedContent = JsonConvert . SerializeObject ( content ) ;
625
+ request . Content = new StringContent ( serializedContent ) ;
626
+ request . Content . Headers . ContentType = new MediaTypeHeaderValue ( "application/vnd.api+json" ) ;
627
+
628
+ // Act
629
+ var response = await _fixture . Client . SendAsync ( request ) ;
630
+
631
+ // Assert
632
+ var personResult = _context . People
633
+ . AsNoTracking ( )
634
+ . Include ( p => p . TodoItems )
635
+ . Single ( p => p . Id == person . Id ) ;
636
+
637
+ Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
638
+ Assert . Empty ( personResult . TodoItems ) ;
639
+ }
640
+
583
641
[ Fact ]
584
642
public async Task Can_Delete_Relationship_By_Patching_Relationship ( )
585
643
{
0 commit comments