-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #322 from SkillsFundingAgency/PA-372-show-delivery…
…-model-when-multiple-exist PA-372 Added support to show DeliveryModel link if there are multiple
- Loading branch information
Showing
15 changed files
with
194 additions
and
25 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
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
57 changes: 57 additions & 0 deletions
57
src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Service/DeliveryModelServiceTests.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,57 @@ | ||
using AutoFixture; | ||
using Moq; | ||
using NUnit.Framework; | ||
using SFA.DAS.EmployerCommitmentsV2.Web.Services; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using SFA.DAS.CommitmentsV2.Types; | ||
using SFA.DAS.EmployerCommitmentsV2.Services.Approvals; | ||
using SFA.DAS.EmployerCommitmentsV2.Services.Approvals.Responses; | ||
using SFA.DAS.Encoding; | ||
|
||
namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Service | ||
{ | ||
[TestFixture] | ||
public class DeliveryModelServiceTests | ||
{ | ||
private DeliveryModelService _mapper; | ||
private Mock<IApprovalsApiClient> _outerApiClient; | ||
private Mock<IEncodingService> _encodingService; | ||
private ProviderCourseDeliveryModels _response; | ||
private long _providerId; | ||
private string _courseCode; | ||
|
||
[SetUp] | ||
public void Arrange() | ||
{ | ||
var fixture = new Fixture(); | ||
_providerId = fixture.Create<long>(); | ||
_courseCode = fixture.Create<string>(); | ||
_response = fixture.Create<ProviderCourseDeliveryModels>(); | ||
|
||
_outerApiClient = new Mock<IApprovalsApiClient>(); | ||
_outerApiClient.Setup(x => x.GetProviderCourseDeliveryModels(_providerId, _courseCode, 1234, It.IsAny<CancellationToken>())).ReturnsAsync(_response); | ||
_encodingService = new Mock<IEncodingService>(); | ||
_encodingService.Setup(x => x.Decode(It.IsAny<string>(), EncodingType.PublicAccountLegalEntityId)) | ||
.Returns(1234); | ||
|
||
_mapper = new DeliveryModelService(_outerApiClient.Object, _encodingService.Object); | ||
} | ||
|
||
[Test] | ||
public async Task ThenReturnsTrueWhenMultipleDeliveryModelsExist() | ||
{ | ||
var result = await _mapper.HasMultipleDeliveryModels(_providerId, _courseCode, "ALEID"); | ||
Assert.IsTrue(result); | ||
} | ||
|
||
[Test] | ||
public async Task ThenReturnsFalseWhenMultipleDeliveryModelsDoNotExist() | ||
{ | ||
_response.DeliveryModels = new List<DeliveryModel> { DeliveryModel.Regular }; | ||
var result = await _mapper.HasMultipleDeliveryModels(_providerId, _courseCode, "ALEID"); | ||
Assert.IsFalse(result); | ||
} | ||
} | ||
} |
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
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
27 changes: 27 additions & 0 deletions
27
src/SFA.DAS.EmployerCommitmentsV2.Web/Services/DeliveryModelService.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,27 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using SFA.DAS.EmployerCommitmentsV2.Services.Approvals; | ||
using SFA.DAS.Encoding; | ||
|
||
namespace SFA.DAS.EmployerCommitmentsV2.Web.Services | ||
{ | ||
public class DeliveryModelService : IDeliveryModelService | ||
{ | ||
private readonly IEncodingService _encodingService; | ||
private readonly IApprovalsApiClient _approvalsApiClient; | ||
|
||
public DeliveryModelService(IApprovalsApiClient approvalsApiClient, IEncodingService encodingService) | ||
{ | ||
_encodingService = encodingService; | ||
_approvalsApiClient = approvalsApiClient; | ||
} | ||
|
||
public async Task<bool> HasMultipleDeliveryModels(long providerId, string courseCode, string accountLegalEntity) | ||
{ | ||
var aleId = _encodingService.Decode(accountLegalEntity, EncodingType.PublicAccountLegalEntityId); | ||
|
||
var response = await _approvalsApiClient.GetProviderCourseDeliveryModels(providerId, courseCode, aleId); | ||
return (response?.DeliveryModels.Count() > 1); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/SFA.DAS.EmployerCommitmentsV2.Web/Services/IDeliveryModelService.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,9 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace SFA.DAS.EmployerCommitmentsV2.Web.Services | ||
{ | ||
public interface IDeliveryModelService | ||
{ | ||
Task<bool> HasMultipleDeliveryModels(long providerId, string courseCode, string accountLegalEntity); | ||
} | ||
} |
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
Oops, something went wrong.