66using  System ; 
77using  System . Linq ; 
88using  System . Threading . Tasks ; 
9+ using  Microsoft . EntityFrameworkCore ; 
910using  Xunit ; 
1011
1112namespace  Abp . EntityFrameworkCore . Tests . Tests 
1213{ 
1314    public  class  Repository_Filtering_Tests  :  EntityFrameworkCoreModuleTestBase 
1415    { 
1516        private  readonly  IRepository < Post ,  Guid >  _postRepository ; 
17+         private  readonly  IRepository < Blog >  _blogRepository ; 
1618        private  readonly  IRepository < Ticket >  _ticketRepository ; 
1719        private  readonly  IUnitOfWorkManager  _unitOfWorkManager ; 
1820        private  readonly  IRepository < TicketListItem >  _ticketListItemRepository ; 
@@ -22,6 +24,7 @@ public Repository_Filtering_Tests()
2224            _unitOfWorkManager  =  Resolve < IUnitOfWorkManager > ( ) ; 
2325
2426            _postRepository  =  Resolve < IRepository < Post ,  Guid > > ( ) ; 
27+             _blogRepository  =  Resolve < IRepository < Blog > > ( ) ; 
2528            _ticketRepository  =  Resolve < IRepository < Ticket > > ( ) ; 
2629            _ticketListItemRepository  =  Resolve < IRepository < TicketListItem > > ( ) ; 
2730        } 
@@ -123,5 +126,28 @@ public async Task Should_Filter_View_With_MustHaveTenantId()
123126            ticketsDefault . Any ( t =>  t . TenantId  ==  42 ) . ShouldBeTrue ( ) ; 
124127            ticketsDefault . Any ( t =>  t . TenantId  !=  42 ) . ShouldBeFalse ( ) ; 
125128        } 
129+         
130+         [ Fact ] 
131+         public  async  Task  Navigation_Properties_Cascade_Delete_Test ( ) 
132+         { 
133+             await  WithUnitOfWorkAsync ( async  ( )  => 
134+             { 
135+                 var  blog  =  await  _blogRepository . GetAll ( ) . Include ( x =>  x . Posts ) . FirstOrDefaultAsync ( b =>  b . Name  ==  "test-blog-1" ) ; 
136+                 blog . Posts . ShouldNotBeEmpty ( ) ; 
137+ 
138+                 blog . Posts . Clear ( ) ; 
139+                 await  _blogRepository . UpdateAsync ( blog ) ; 
140+             } ) ; 
141+             
142+             await  WithUnitOfWorkAsync ( async  ( )  => 
143+             { 
144+                 using  ( _unitOfWorkManager . Current . DisableFilter ( AbpDataFilters . SoftDelete ) ) 
145+                 { 
146+                     var  blog  =  await  _blogRepository . GetAll ( ) . Include ( x =>  x . Posts ) . FirstOrDefaultAsync ( b =>  b . Name  ==  "test-blog-1" ) ; 
147+                     blog . Posts . ShouldNotBeEmpty ( ) ; 
148+                     blog . Posts . ShouldAllBe ( x =>  x . IsDeleted ) ; 
149+                 } 
150+             } ) ; 
151+         } 
126152    } 
127153} 
0 commit comments