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)
64
64
public async ValueTask DeleteAsync ( string id )
65
65
{
66
66
ResetCache ( ) ;
67
- memoryCache . Remove ( id ) ;
68
67
await repository . DeleteAsync ( id ) ;
69
68
}
70
69
Original file line number Diff line number Diff line change @@ -30,4 +30,36 @@ public async Task ShouldNotCacheWhenDifferentQueries()
30
30
allWithTag2 . Count . Should ( ) . Be ( 1 ) ;
31
31
allWithTag2 . Single ( ) . Tags . Single ( ) . Content . Should ( ) . Be ( "tag 2" ) ;
32
32
}
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
+ }
33
65
}
Original file line number Diff line number Diff line change @@ -40,9 +40,9 @@ public void ShouldDisplaySitemap()
40
40
var sitemap = new SitemapUrlSet
41
41
{
42
42
Urls = new List < SitemapUrl >
43
- {
44
- new ( ) { Location = "loc" , LastModified = "Now" } ,
45
- } ,
43
+ {
44
+ new ( ) { Location = "loc" , LastModified = "Now" } ,
45
+ } ,
46
46
} ;
47
47
sitemapMock . Setup ( s => s . CreateSitemapAsync ( ) )
48
48
. ReturnsAsync ( sitemap ) ;
@@ -65,9 +65,9 @@ public void ShouldShowLoadingWhenGenerating()
65
65
var sitemap = new SitemapUrlSet
66
66
{
67
67
Urls = new List < SitemapUrl >
68
- {
69
- new ( ) { Location = "loc" , LastModified = "Now" } ,
70
- } ,
68
+ {
69
+ new ( ) { Location = "loc" , LastModified = "Now" } ,
70
+ } ,
71
71
} ;
72
72
sitemapMock . Setup ( s => s . CreateSitemapAsync ( ) )
73
73
. Returns ( async ( ) =>
You can’t perform that action at this time.
0 commit comments