File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
LinkDotNet.Blog.IntegrationTests/Infrastructure/Persistence/Sql
LinkDotNet.Blog.UnitTests/Infrastructure/Persistence/InMemory
LinkDotNet.Infrastructure/Persistence/Sql Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -104,5 +104,17 @@ public async Task ShouldFilterAndOrder()
104104 retrievedPosts [ 0 ] . Id . Should ( ) . Be ( olderPost . Id ) ;
105105 retrievedPosts [ 1 ] . Id . Should ( ) . Be ( newerPost . Id ) ;
106106 }
107+
108+ [ Fact ]
109+ public async Task ShouldDelete ( )
110+ {
111+ var blogPost = new BlogPostBuilder ( ) . Build ( ) ;
112+ await BlogPostRepository . StoreAsync ( blogPost ) ;
113+
114+ await BlogPostRepository . DeleteAsync ( blogPost . Id ) ;
115+
116+ ( await DbContext . BlogPosts . AsNoTracking ( ) . AnyAsync ( b => b . Id == blogPost . Id ) ) . Should ( ) . BeFalse ( ) ;
117+ ( await DbContext . Tags . AsNoTracking ( ) . AnyAsync ( t => t . Id == blogPost . Id ) ) . Should ( ) . BeFalse ( ) ;
118+ }
107119 }
108120}
Original file line number Diff line number Diff line change @@ -61,5 +61,16 @@ public async Task ShouldFilterAndOrder()
6161 retrievedPosts [ 0 ] . Id . Should ( ) . Be ( olderPost . Id ) ;
6262 retrievedPosts [ 1 ] . Id . Should ( ) . Be ( newerPost . Id ) ;
6363 }
64+
65+ [ Fact ]
66+ public async Task ShouldDelete ( )
67+ {
68+ var blogPost = new BlogPostBuilder ( ) . Build ( ) ;
69+ await sut . StoreAsync ( blogPost ) ;
70+
71+ await sut . DeleteAsync ( blogPost . Id ) ;
72+
73+ ( await sut . GetByIdAsync ( blogPost . Id ) ) . Should ( ) . BeNull ( ) ;
74+ }
6475 }
6576}
Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ public BlogPostContext(DbContextOptions options)
1313
1414 public DbSet < BlogPost > BlogPosts { get ; set ; }
1515
16+ public DbSet < Tag > Tags { get ; set ; }
17+
1618 protected override void OnModelCreating ( ModelBuilder modelBuilder )
1719 {
1820 modelBuilder . Entity < BlogPost > ( )
You can’t perform that action at this time.
0 commit comments