Skip to content

Conversation

@MattParkerDev
Copy link
Contributor

@MattParkerDev MattParkerDev commented May 17, 2025

Fixes #311

Tests pass, I haven't tested any further than that.

Copy link
Member

@MihailsKuzmins MihailsKuzmins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MattParkerDev thanks. It looks like bUnit also registers an IMemoryCache, therefore, unit tests have not been able to catch this error and IMemoryCache was successfully injected into MudMarkdownValueProvider.

Therefore, could you please add a new unit test to prevent this error from happening in MudBlazor.Markdown.Tests?
Utils/ServiceCollectionExTests/AddMudMarkdownServicesShould.cs
※ please use tabs for indentation.

namespace MudBlazor.Markdown.Tests.Utils.ServiceCollectionExTests;

public sealed class AddMudMarkdownServicesShould
{
	[Fact]
	public void RegisterServices()
	{
		using var serviceProvider = new ServiceCollection()
			.AddMudMarkdownServices()
			.BuildServiceProvider();

		serviceProvider.GetRequiredService<IMudMarkdownMemoryCache>()
			.Should()
			.BeOfType<MudMarkdownMemoryCache>();

		serviceProvider.GetService<IMemoryCache>()
			.Should()
			.BeNull();

		serviceProvider.GetRequiredService<IMudMarkdownThemeService>()
			.Should()
			.BeOfType<MudMarkdownThemeService>();

		serviceProvider.GetRequiredService<IMudMarkdownValueProvider>()
			.Should()
			.BeOfType<MudMarkdownValueProvider>();
	}
}

@MattParkerDev
Copy link
Contributor Author

@MihailsKuzmins test added :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to construct MudMarkdownValueProvider without explicit addition of AddMemoryCache()

2 participants