Skip to content

Commit cc77c26

Browse files
committed
Decorator Test
1 parent f0beef9 commit cc77c26

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

LinkDotNet.Blog.IntegrationTests/Web/RegistrationExtensions/StorageProviderExtensionsTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System;
22
using System.Linq;
33
using FluentAssertions;
4+
using LinkDotNet.Blog.Domain;
45
using LinkDotNet.Blog.Infrastructure.Persistence;
6+
using LinkDotNet.Blog.Web;
57
using LinkDotNet.Blog.Web.RegistrationExtensions;
68
using Microsoft.Extensions.Configuration;
79
using Microsoft.Extensions.DependencyInjection;
@@ -42,5 +44,21 @@ public void ShouldThrowExceptionWhenNotKnown()
4244

4345
act.Should().Throw<Exception>();
4446
}
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+
}
4563
}
4664
}

0 commit comments

Comments
 (0)