File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
LinkDotNet.Blog.IntegrationTests/Web/RegistrationExtensions Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Linq ;
3
3
using FluentAssertions ;
4
+ using LinkDotNet . Blog . Domain ;
4
5
using LinkDotNet . Blog . Infrastructure . Persistence ;
6
+ using LinkDotNet . Blog . Web ;
5
7
using LinkDotNet . Blog . Web . RegistrationExtensions ;
6
8
using Microsoft . Extensions . Configuration ;
7
9
using Microsoft . Extensions . DependencyInjection ;
@@ -42,5 +44,21 @@ public void ShouldThrowExceptionWhenNotKnown()
42
44
43
45
act . Should ( ) . Throw < Exception > ( ) ;
44
46
}
47
+
48
+ [ Fact ]
49
+ public void ShouldHaveCacheRepositoryOnlyForBlogPosts ( )
50
+ {
51
+ var collection = new ServiceCollection ( ) ;
52
+ var config = new Mock < IConfiguration > ( ) ;
53
+ config . Setup ( c => c [ "PersistenceProvider" ] )
54
+ . Returns ( "SqliteServer" ) ;
55
+ collection . AddScoped ( _ => new AppConfiguration { ConnectionString = "Filename=:memory:" } ) ;
56
+
57
+ collection . AddStorageProvider ( config . Object ) ;
58
+
59
+ var serviceProvider = collection . BuildServiceProvider ( ) ;
60
+ serviceProvider . GetService < IRepository < BlogPost > > ( ) . Should ( ) . BeOfType < CachedRepository < BlogPost > > ( ) ;
61
+ serviceProvider . GetService < IRepository < Skill > > ( ) . Should ( ) . NotBeOfType < CachedRepository < BlogPost > > ( ) ;
62
+ }
45
63
}
46
64
}
You can’t perform that action at this time.
0 commit comments