Skip to content

Commit f353ef5

Browse files
Added a new function to the caching provider to decrement the caching prefix counter
1 parent 4668624 commit f353ef5

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

src/DotNetToolkit.Repository/Configuration/Caching/CacheProviderManager.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,22 @@ public sealed class CacheProviderManager
1717
/// <summary>
1818
/// Gets the global caching prefix counter.
1919
/// </summary>
20-
internal static int GlobalCachingPrefixCounter { get { return _counter; } }
20+
public static int GlobalCachingPrefixCounter { get { return _counter; } }
2121

2222
/// <summary>
23-
/// Clears the cache.
23+
/// Increments the caching prefix counter.
2424
/// </summary>
2525
public static void IncrementCounter()
2626
{
2727
Interlocked.Increment(ref _counter);
2828
}
29+
30+
/// <summary>
31+
/// Decrements the caching prefix counter.
32+
/// </summary>
33+
public static void DecrementCounter()
34+
{
35+
Interlocked.Decrement(ref _counter);
36+
}
2937
}
3038
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
namespace DotNetToolkit.Repository.Test
2+
{
3+
using Configuration.Caching;
4+
using Xunit;
5+
6+
public class CachingProviderManagerTests
7+
{
8+
[Fact]
9+
public void IncrementCounter()
10+
{
11+
var counter = CacheProviderManager.GlobalCachingPrefixCounter;
12+
13+
CacheProviderManager.IncrementCounter();
14+
15+
Assert.Equal(counter + 1, CacheProviderManager.GlobalCachingPrefixCounter);
16+
}
17+
18+
[Fact]
19+
public void DecrementCounter()
20+
{
21+
var counter = CacheProviderManager.GlobalCachingPrefixCounter;
22+
23+
CacheProviderManager.DecrementCounter();
24+
25+
Assert.Equal(counter - 1, CacheProviderManager.GlobalCachingPrefixCounter);
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)