-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extensions package for a named client
- Loading branch information
1 parent
c88baee
commit 4374ca3
Showing
24 changed files
with
600 additions
and
405 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
40 changes: 40 additions & 0 deletions
40
Kentico.Kontent.Delivery.Caching.Tests/CacheManagerFactoryTests.cs
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,40 @@ | ||
using FakeItEasy; | ||
using FluentAssertions; | ||
using Kentico.Kontent.Delivery.Caching.Factories; | ||
using Microsoft.Extensions.Caching.Distributed; | ||
using Microsoft.Extensions.Caching.Memory; | ||
using Microsoft.Extensions.Options; | ||
using Xunit; | ||
|
||
namespace Kentico.Kontent.Delivery.Caching.Tests | ||
{ | ||
public class CacheManagerFactoryTests | ||
{ | ||
private IOptions<DeliveryCacheOptions> _options; | ||
private IDistributedCache _distributedCache; | ||
private IMemoryCache _memoryCache; | ||
|
||
public CacheManagerFactoryTests() | ||
{ | ||
_options = A.Fake<IOptions<DeliveryCacheOptions>>(); | ||
_distributedCache = A.Fake<IDistributedCache>(); | ||
_memoryCache = A.Fake<IMemoryCache>(); | ||
} | ||
|
||
[Fact] | ||
public void Create_DistributedCache() | ||
{ | ||
var deliveryCacheManager = CacheManagerFactory.Create(_distributedCache, _options); | ||
|
||
deliveryCacheManager.Should().NotBeNull(); | ||
} | ||
|
||
[Fact] | ||
public void Create_MemoryCache() | ||
{ | ||
var deliveryCacheManager = CacheManagerFactory.Create(_memoryCache, _options); | ||
|
||
deliveryCacheManager.Should().NotBeNull(); | ||
} | ||
} | ||
} |
60 changes: 0 additions & 60 deletions
60
Kentico.Kontent.Delivery.Caching.Tests/Factories/DeliveryCacheManagerFactoryTests.cs
This file was deleted.
Oops, something went wrong.
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
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
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
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
37 changes: 37 additions & 0 deletions
37
Kentico.Kontent.Delivery.Caching/Factories/CacheManagerFactory.cs
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,37 @@ | ||
using Kentico.Kontent.Delivery.Abstractions; | ||
using Microsoft.Extensions.Caching.Distributed; | ||
using Microsoft.Extensions.Caching.Memory; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Kentico.Kontent.Delivery.Caching.Factories | ||
{ | ||
/// <summary> | ||
/// A factory for manually create an <see cref="IDeliveryCacheManager"/> instance. | ||
/// </summary> | ||
public static class CacheManagerFactory | ||
{ | ||
/// <summary> | ||
/// Creates an <see cref="IDeliveryCacheManager"/> instance with a distributed cache. | ||
/// </summary> | ||
/// <param name="distributedCache">A <see cref="IDistributedCache"/> instance.</param> | ||
/// <param name="options">A <see cref="DeliveryCacheOptions"/></param> | ||
/// <returns>The <see cref="IDeliveryCacheManager"/> instance with a distribute cache.</returns> | ||
public static IDeliveryCacheManager Create(IDistributedCache distributedCache, | ||
IOptions<DeliveryCacheOptions> options) | ||
{ | ||
return new DistributedCacheManager(distributedCache, options); | ||
} | ||
|
||
/// <summary> | ||
/// Creates an <see cref="IDeliveryCacheManager"/> instance with a memory cache. | ||
/// </summary> | ||
/// <param name="memoryCache">A <see cref="IMemoryCache"/> instance.</param> | ||
/// <param name="options">A <see cref="DeliveryCacheOptions"/></param> | ||
/// <returns>The <see cref="IDeliveryCacheManager"/> instance with a memory cache.</returns> | ||
public static IDeliveryCacheManager Create(IMemoryCache memoryCache, | ||
IOptions<DeliveryCacheOptions> options) | ||
{ | ||
return new MemoryCacheManager(memoryCache, options); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.