Skip to content

Commit 44462c9

Browse files
🐛 Inject IMudMarkdownMemoryCache into MudMarkdownValueProvider (#313)
1 parent 79eb0ab commit 44462c9

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/MudBlazor.Markdown/Services/MudMarkdownValueProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ namespace MudBlazor;
44

55
internal sealed class MudMarkdownValueProvider : IMudMarkdownValueProvider
66
{
7-
private readonly IMemoryCache _memoryCache;
7+
private readonly IMudMarkdownMemoryCache _memoryCache;
88
private readonly MemoryCacheEntryOptions _memoryCacheEntryOptions;
99
private static readonly HttpClient HttpClient = new();
1010

11-
public MudMarkdownValueProvider(IMemoryCache memoryCache, IOptions<MudMarkdownMemoryCacheEntryOptions> options)
11+
public MudMarkdownValueProvider(IMudMarkdownMemoryCache memoryCache, IOptions<MudMarkdownMemoryCacheEntryOptions> options)
1212
{
1313
_memoryCache = memoryCache;
1414
_memoryCacheEntryOptions = options.Value;

tests/MudBlazor.Markdown.Tests/Utils/ServiceCollectionExTests/AddMudMarkdownServicesShould.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,28 @@ public void RegisterScopedMemoryCache()
5959
.Should()
6060
.NotBe(scopedInstance);
6161
}
62+
63+
[Fact]
64+
public void RegisterServices()
65+
{
66+
using var serviceProvider = new ServiceCollection()
67+
.AddMudMarkdownServices()
68+
.BuildServiceProvider();
69+
70+
serviceProvider.GetRequiredService<IMudMarkdownMemoryCache>()
71+
.Should()
72+
.BeOfType<MudMarkdownMemoryCache>();
73+
74+
serviceProvider.GetService<IMemoryCache>()
75+
.Should()
76+
.BeNull();
77+
78+
serviceProvider.GetRequiredService<IMudMarkdownThemeService>()
79+
.Should()
80+
.BeOfType<MudMarkdownThemeService>();
81+
82+
serviceProvider.GetRequiredService<IMudMarkdownValueProvider>()
83+
.Should()
84+
.BeOfType<MudMarkdownValueProvider>();
85+
}
6286
}

0 commit comments

Comments
 (0)