Skip to content

Commit c5a57d4

Browse files
Refactor tests and update version to 2.1.0
Moved all unit tests from UnitTest1.cs to CacheServiceTests.cs for better organization. Incremented package version to 2.1.0. Cleaned up unnecessary using directives in several files. No changes to test logic or core functionality.
1 parent 62f6fa6 commit c5a57d4

7 files changed

Lines changed: 26 additions & 19 deletions

File tree

AspNetCoreCacheKit.Tests/UnitTest1.cs renamed to AspNetCoreCacheKit.Tests/CacheServiceTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
using AspNetCoreCacheKit;
2-
using AspNetCoreCacheKit.Models;
1+
using AspNetCoreCacheKit.Models;
32
using AspNetCoreCacheKit.Tests.Helpers;
43
using Microsoft.Extensions.Caching.Memory;
54
using Microsoft.Extensions.Options;
6-
using Xunit;
75

86
namespace AspNetCoreCacheKit.Tests
97
{

AspNetCoreCacheKit.Tests/Helpers/CacheServiceFactory.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
using AspNetCoreCacheKit.Models;
22
using Microsoft.Extensions.Caching.Memory;
33
using Microsoft.Extensions.Options;
4-
using System;
5-
using System.Collections.Generic;
6-
using System.Linq;
7-
using System.Text;
8-
using System.Threading.Tasks;
94

105
namespace AspNetCoreCacheKit.Tests.Helpers
116
{

AspNetCoreCacheKit/AspNetCoreCacheKit.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<IsPackable>true</IsPackable>
99
<PackageId>AspNetCoreCacheKit</PackageId>
10-
<Version>2.0.0</Version>
10+
<Version>2.1.0</Version>
1111
<Authors>Simone Marano</Authors>
1212
<Description>Lightweight caching toolkit for ASP.NET Core with group-based keys, per-entry and per-group duration, configurable via appsettings.json and DI-ready design.</Description>
1313
<PackageLicenseExpression>MIT</PackageLicenseExpression>

AspNetCoreCacheKit/Extensions/CacheServiceExtensions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
using AspNetCoreCacheKit.Models;
33
using Microsoft.Extensions.Configuration;
44
using Microsoft.Extensions.DependencyInjection;
5-
using Microsoft.Extensions.Options;
6-
using System.ComponentModel.DataAnnotations;
7-
using System.Diagnostics.CodeAnalysis;
85

96
namespace AspNetCoreCacheKit.Extensions
107
{

AspNetCoreCacheKit/Models/NullCacheEntry.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
using Microsoft.Extensions.Caching.Memory;
22
using Microsoft.Extensions.Primitives;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
83

94
namespace AspNetCoreCacheKit.Models
105
{

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
---
1313

14+
## [2.1.0] - 2026-03-24
15+
16+
---
17+
1418
## [2.0.0] - 2026-03-24
1519

1620
### Added
@@ -62,7 +66,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6266
- MIT license
6367

6468
---
65-
66-
[Unreleased]: https://github.com/simoneM93/AspNetCoreCacheKit/compare/v2.0.0...HEAD
69+
[Unreleased]: https://github.com/simoneM93/AspNetCoreCacheKit/compare/v2.1.0...HEAD
70+
[2.1.0]: https://github.com/simoneM93/AspNetCoreCacheKit/compare/v2.0.0...v2.1.0
6771
[2.0.0]: https://github.com/simoneM93/AspNetCoreCacheKit/compare/v1.0.0...v2.0.0
6872
[1.0.0]: https://github.com/simoneM93/AspNetCoreCacheKit/releases/tag/v1.0.0

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ A lightweight caching library for ASP.NET Core featuring **group-based keys**, c
2222
-**Configuration validation** with DataAnnotations
2323
- 📐 **Nullable reference types** support
2424
- 🎛️ **`appsettings.json`** configuration with sensible defaults
25+
- 🧪 **DI-ready** — register with one line, mock `ICacheService` in tests
2526

2627
---
2728

@@ -179,6 +180,23 @@ Setting `IsEnabled: false` is useful in development or testing environments wher
179180

180181
---
181182

183+
## 🧪 Testing
184+
185+
`ICacheService` is a plain interface — mock it directly in unit tests:
186+
187+
```csharp
188+
var cacheMock = new Mock<ICacheService>();
189+
190+
cacheMock
191+
.Setup(c => c.GetOrCreateAsync(
192+
"users", "1",
193+
It.IsAny<Func<ICacheEntry, Task<User>>>(),
194+
It.IsAny<CancellationToken>()))
195+
.ReturnsAsync(new User { Id = 1, Name = "Simone" });
196+
```
197+
198+
---
199+
182200
## ❤️ Support
183201

184202
If you find AspNetCoreCacheKit useful, consider sponsoring its development.

0 commit comments

Comments
 (0)