Skip to content

Commit 3cc8e99

Browse files
linkdotnetegil
andauthored
feat: Added IMemoryCache by default to the container (#955)
* feat: Added IMemoryCache by default to the container * Better wording Co-authored-by: Egil Hansen <[email protected]> * Use predefined extension method to add memory cache Co-authored-by: Egil Hansen <[email protected]>
1 parent dbfe251 commit 3cc8e99

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ All notable changes to **bUnit** will be documented in this file. The project ad
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- Added `IMemoryCache` by default to the Services container. By [@linkdotnet](https://github.com/linkdotnet).
12+
913
### Fixed
1014

1115
- Added support in `FakeNavigationManager` to handle umlauts.

src/bunit.web/Extensions/TestServiceProviderExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Microsoft.AspNetCore.Components.Authorization;
66
using Microsoft.AspNetCore.Components.Routing;
77
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
8+
using Microsoft.Extensions.Caching.Memory;
89
using Microsoft.Extensions.Localization;
910

1011
namespace Bunit.Extensions;
@@ -54,6 +55,8 @@ public static IServiceCollection AddDefaultTestContextServices(this IServiceColl
5455
services.AddSingleton<BunitHtmlParser>();
5556
services.AddSingleton<IRenderedComponentActivator, RenderedComponentActivator>();
5657

58+
services.AddMemoryCache();
59+
5760
#if NET6_0_OR_GREATER
5861
services.AddSingleton<IErrorBoundaryLogger, BunitErrorBoundaryLogger>();
5962
#endif

src/bunit.web/bunit.web.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="$(DotNet3Version)" />
2525
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(DotNet3Version)" />
2626
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="$(DotNet3Version)" />
27+
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="$(DotNet3Version)" />
2728
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.1" />
2829
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="3.2.1" />
2930
</ItemGroup>
@@ -32,13 +33,15 @@
3233
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="$(DotNet5Version)" />
3334
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(DotNet5Version)" />
3435
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="$(DotNet5Version)" />
36+
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="$(DotNet5Version)" />
3537
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(DotNet5Version)" />
3638
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="$(DotNet5Version)" />
3739
</ItemGroup>
3840

3941
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
4042
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="$(DotNet6Version)" />
4143
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="$(DotNet6Version)" />
44+
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="$(DotNet6Version)" />
4245
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(DotNet6Version)" />
4346
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(DotNet6Version)" />
4447
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="$(DotNet6Version)" />
@@ -47,6 +50,7 @@
4750
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
4851
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="$(DotNet7Version)" />
4952
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="$(DotNet7Version)" />
53+
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="$(DotNet7Version)" />
5054
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(DotNet7Version)" />
5155
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(DotNet7Version)" />
5256
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="$(DotNet7Version)" />
@@ -82,4 +86,4 @@
8286
<Using Include="Microsoft.JSInterop" />
8387
</ItemGroup>
8488

85-
</Project>
89+
</Project>

0 commit comments

Comments
 (0)