-
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 0c83d09
Showing
19 changed files
with
654 additions
and
381 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
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
59 changes: 59 additions & 0 deletions
59
....Kontent.Delivery.Extensions.DependencyInjection.Tests/DeliveryClientCacheFactoryTests.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,59 @@ | ||
using FakeItEasy; | ||
using FluentAssertions; | ||
using Kentico.Kontent.Delivery.Abstractions; | ||
using Kentico.Kontent.Delivery.Caching; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Options; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Kentico.Kontent.Delivery.Extensions.DependencyInjection.Tests | ||
{ | ||
public class DeliveryClientCacheFactoryTests | ||
{ | ||
private readonly IOptionsMonitor<DeliveryCacheOptions> _deliveryCacheOptionsMock; | ||
private readonly IDeliveryClientFactory _innerDeliveryClientFactoryMock; | ||
private readonly IServiceProvider _serviceProvider; | ||
|
||
private const string _clientName = "ClientName"; | ||
|
||
public DeliveryClientCacheFactoryTests() | ||
{ | ||
_deliveryCacheOptionsMock = A.Fake<IOptionsMonitor<DeliveryCacheOptions>>(); | ||
_innerDeliveryClientFactoryMock = A.Fake<IDeliveryClientFactory>(); | ||
_serviceProvider = new ServiceCollection().BuildServiceProvider(); | ||
} | ||
|
||
[Fact] | ||
public void GetNamedCacheClient_WithCorrectName_GetClient() | ||
{ | ||
var deliveryCacheOptions = new DeliveryCacheOptions(); | ||
A.CallTo(() => _deliveryCacheOptionsMock.Get(_clientName)) | ||
.Returns(deliveryCacheOptions); | ||
|
||
var deliveryClientFactory = new DeliveryClientCacheFactory(_innerDeliveryClientFactoryMock, _deliveryCacheOptionsMock, _serviceProvider); | ||
|
||
var result = deliveryClientFactory.Get(_clientName); | ||
|
||
result.Should().NotBeNull(); | ||
} | ||
|
||
[Fact] | ||
public void GetNamedCacheClient_WithWrongName_GetNull() | ||
{ | ||
var deliveryCacheOptions = new DeliveryCacheOptions(); | ||
A.CallTo(() => _deliveryCacheOptionsMock.Get(_clientName)) | ||
.Returns(deliveryCacheOptions); | ||
|
||
var deliveryClientFactory = new DeliveryClientCacheFactory(_innerDeliveryClientFactoryMock, _deliveryCacheOptionsMock, _serviceProvider); | ||
|
||
var result = deliveryClientFactory.Get("WrongName"); | ||
|
||
result.Should().NotBeNull(); | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
Kentico.Kontent.Delivery.Extensions.DependencyInjection.Tests/DeliveryClientFactoryTests.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,52 @@ | ||
using FakeItEasy; | ||
using FluentAssertions; | ||
using Kentico.Kontent.Delivery.Abstractions; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Options; | ||
using System; | ||
using Xunit; | ||
|
||
namespace Kentico.Kontent.Delivery.Extensions.DependencyInjection.Tests | ||
{ | ||
public class DeliveryClientFactoryTests | ||
{ | ||
private readonly IOptionsMonitor<DeliveryOptions> _deliveryOptionsMock; | ||
private readonly IServiceProvider _serviceProvider; | ||
|
||
private const string _clientName = "ClientName"; | ||
|
||
public DeliveryClientFactoryTests() | ||
{ | ||
_deliveryOptionsMock = A.Fake<IOptionsMonitor<DeliveryOptions>>(); | ||
_serviceProvider = new ServiceCollection().BuildServiceProvider(); | ||
} | ||
|
||
[Fact] | ||
public void GetNamedClient_WithCorrectName_GetClient() | ||
{ | ||
var deliveryOptions = new DeliveryOptions() { ProjectId = Guid.NewGuid().ToString() }; | ||
A.CallTo(() => _deliveryOptionsMock.Get(_clientName)) | ||
.Returns(deliveryOptions); | ||
|
||
var deliveryClientFactory = new DeliveryClientFactory(_deliveryOptionsMock, _serviceProvider); | ||
|
||
var result = deliveryClientFactory.Get(_clientName); | ||
|
||
result.Should().NotBeNull(); | ||
} | ||
|
||
[Fact] | ||
public void GetNamedClient_WithWrongName_GetNull() | ||
{ | ||
var deliveryOptions = new DeliveryOptions() { ProjectId = Guid.NewGuid().ToString() }; | ||
A.CallTo(() => _deliveryOptionsMock.Get(_clientName)) | ||
.Returns(deliveryOptions); | ||
|
||
var deliveryClientFactory = new DeliveryClientFactory(_deliveryOptionsMock, _serviceProvider); | ||
|
||
var result = deliveryClientFactory.Get("WrongName"); | ||
|
||
result.Should().BeNull(); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...dencyInjection.Tests/Kentico.Kontent.Delivery.Extensions.DependencyInjection.Tests.csproj
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,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FakeItEasy" Version="6.2.1" /> | ||
<PackageReference Include="FluentAssertions" Version="5.10.3" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="1.3.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Kentico.Kontent.Delivery.Abstractions\Kentico.Kontent.Delivery.Abstractions.csproj" /> | ||
<ProjectReference Include="..\Kentico.Kontent.Delivery.Extensions.DependencyInjection\Kentico.Kontent.Delivery.Extensions.DependencyInjection.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.