-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbe5c64
commit a87adae
Showing
2 changed files
with
127 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
using FastCache.Extensions; | ||
|
||
namespace FastCache.CachedTests; | ||
|
||
public sealed class CachedTests_Extensions | ||
{ | ||
[Fact] | ||
public void CacheK1_Caches() | ||
{ | ||
var key = GetTestKey(); | ||
var value = GetRandomString(); | ||
|
||
value.Cache(key, TimeSpan.MaxValue); | ||
|
||
var found = Cached<string>.TryGet(key, out var cached); | ||
|
||
Assert.True(found); | ||
Assert.Equal(value, cached.Value); | ||
} | ||
|
||
[Fact] | ||
public void CacheK2_Caches() | ||
{ | ||
var k1 = GetTestKey(); | ||
var k2 = GetTestKey(); | ||
var value = GetRandomString(); | ||
|
||
value.Cache(k1, k2, TimeSpan.MaxValue); | ||
|
||
var found = Cached<string>.TryGet(k1, k2, out var cached); | ||
|
||
Assert.True(found); | ||
Assert.Equal(value, cached.Value); | ||
} | ||
|
||
[Fact] | ||
public void CacheK3_Caches() | ||
{ | ||
var k1 = GetTestKey(); | ||
var k2 = GetTestKey(); | ||
var k3 = GetTestKey(); | ||
var value = GetRandomString(); | ||
|
||
value.Cache(k1, k2, k3, TimeSpan.MaxValue); | ||
|
||
var found = Cached<string>.TryGet(k1, k2, k3, out var cached); | ||
|
||
Assert.True(found); | ||
Assert.Equal(value, cached.Value); | ||
} | ||
|
||
[Fact] | ||
public void CacheK4_Caches() | ||
{ | ||
var k1 = GetTestKey(); | ||
var k2 = GetTestKey(); | ||
var k3 = GetTestKey(); | ||
var k4 = GetTestKey(); | ||
var value = GetRandomString(); | ||
|
||
value.Cache(k1, k2, k3, k4, TimeSpan.MaxValue); | ||
|
||
var found = Cached<string>.TryGet(k1, k2, k3, k4, out var cached); | ||
|
||
Assert.True(found); | ||
Assert.Equal(value, cached.Value); | ||
} | ||
|
||
[Fact] | ||
public void CacheK5_Caches() | ||
{ | ||
var k1 = GetTestKey(); | ||
var k2 = GetTestKey(); | ||
var k3 = GetTestKey(); | ||
var k4 = GetTestKey(); | ||
var k5 = GetTestKey(); | ||
var value = GetRandomString(); | ||
|
||
value.Cache(k1, k2, k3, k4, k5, TimeSpan.MaxValue); | ||
|
||
var found = Cached<string>.TryGet(k1, k2, k3, k4, k5, out var cached); | ||
|
||
Assert.True(found); | ||
Assert.Equal(value, cached.Value); | ||
} | ||
|
||
[Fact] | ||
public void CacheK6_Caches() | ||
{ | ||
var k1 = GetTestKey(); | ||
var k2 = GetTestKey(); | ||
var k3 = GetTestKey(); | ||
var k4 = GetTestKey(); | ||
var k5 = GetTestKey(); | ||
var k6 = GetTestKey(); | ||
var value = GetRandomString(); | ||
|
||
value.Cache(k1, k2, k3, k4, k5, k6, TimeSpan.MaxValue); | ||
|
||
var found = Cached<string>.TryGet(k1, k2, k3, k4, k5, k6, out var cached); | ||
|
||
Assert.True(found); | ||
Assert.Equal(value, cached.Value); | ||
} | ||
|
||
[Fact] | ||
public void CacheK7_Caches() | ||
{ | ||
var k1 = GetTestKey(); | ||
var k2 = GetTestKey(); | ||
var k3 = GetTestKey(); | ||
var k4 = GetTestKey(); | ||
var k5 = GetTestKey(); | ||
var k6 = GetTestKey(); | ||
var k7 = GetTestKey(); | ||
var value = GetRandomString(); | ||
|
||
value.Cache(k1, k2, k3, k4, k5, k6, k7, TimeSpan.MaxValue); | ||
|
||
var found = Cached<string>.TryGet(k1, k2, k3, k4, k5, k6, k7, out var cached); | ||
|
||
Assert.True(found); | ||
Assert.Equal(value, cached.Value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters