File tree Expand file tree Collapse file tree 3 files changed +38
-7
lines changed
LinkDotNet.Blog.Infrastructure/Persistence
LinkDotNet.Blog.IntegrationTests/Infrastructure/Persistence
LinkDotNet.Blog.UnitTests/Web/Pages/Admin Expand file tree Collapse file tree 3 files changed +38
-7
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,6 @@ public async ValueTask StoreAsync(T entity)
6464 public async ValueTask DeleteAsync ( string id )
6565 {
6666 ResetCache ( ) ;
67- memoryCache . Remove ( id ) ;
6867 await repository . DeleteAsync ( id ) ;
6968 }
7069
Original file line number Diff line number Diff line change @@ -30,4 +30,36 @@ public async Task ShouldNotCacheWhenDifferentQueries()
3030 allWithTag2 . Count . Should ( ) . Be ( 1 ) ;
3131 allWithTag2 . Single ( ) . Tags . Single ( ) . Content . Should ( ) . Be ( "tag 2" ) ;
3232 }
33+
34+ [ Fact ]
35+ public async Task ShouldResetOnDelete ( )
36+ {
37+ var bp1 = new BlogPostBuilder ( ) . WithTitle ( "1" ) . Build ( ) ;
38+ var bp2 = new BlogPostBuilder ( ) . WithTitle ( "2" ) . Build ( ) ;
39+ var sut = new CachedRepository < BlogPost > ( Repository , new MemoryCache ( new MemoryCacheOptions ( ) ) ) ;
40+ await sut . StoreAsync ( bp1 ) ;
41+ await sut . StoreAsync ( bp2 ) ;
42+ await sut . GetAllAsync ( ) ;
43+ await sut . DeleteAsync ( bp1 . Id ) ;
44+
45+ var db = await sut . GetAllAsync ( ) ;
46+
47+ db . Single ( ) . Title . Should ( ) . Be ( "2" ) ;
48+ }
49+
50+ [ Fact ]
51+ public async Task ShouldResetOnSave ( )
52+ {
53+ var bp1 = new BlogPostBuilder ( ) . WithTitle ( "1" ) . Build ( ) ;
54+ var bp2 = new BlogPostBuilder ( ) . WithTitle ( "2" ) . Build ( ) ;
55+ var sut = new CachedRepository < BlogPost > ( Repository , new MemoryCache ( new MemoryCacheOptions ( ) ) ) ;
56+ await sut . StoreAsync ( bp1 ) ;
57+ await sut . GetAllAsync ( ) ;
58+ bp1 . Update ( bp2 ) ;
59+ await sut . StoreAsync ( bp1 ) ;
60+
61+ var db = await sut . GetAllAsync ( ) ;
62+
63+ db . Single ( ) . Title . Should ( ) . Be ( "2" ) ;
64+ }
3365}
Original file line number Diff line number Diff line change @@ -40,9 +40,9 @@ public void ShouldDisplaySitemap()
4040 var sitemap = new SitemapUrlSet
4141 {
4242 Urls = new List < SitemapUrl >
43- {
44- new ( ) { Location = "loc" , LastModified = "Now" } ,
45- } ,
43+ {
44+ new ( ) { Location = "loc" , LastModified = "Now" } ,
45+ } ,
4646 } ;
4747 sitemapMock . Setup ( s => s . CreateSitemapAsync ( ) )
4848 . ReturnsAsync ( sitemap ) ;
@@ -65,9 +65,9 @@ public void ShouldShowLoadingWhenGenerating()
6565 var sitemap = new SitemapUrlSet
6666 {
6767 Urls = new List < SitemapUrl >
68- {
69- new ( ) { Location = "loc" , LastModified = "Now" } ,
70- } ,
68+ {
69+ new ( ) { Location = "loc" , LastModified = "Now" } ,
70+ } ,
7171 } ;
7272 sitemapMock . Setup ( s => s . CreateSitemapAsync ( ) )
7373 . Returns ( async ( ) =>
You can’t perform that action at this time.
0 commit comments