-
Notifications
You must be signed in to change notification settings - Fork 4
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 #402 from SkillsFundingAgency/DPP-1586_DisplayOrga…
…nisationsAndAgreements DPP-1586 Display Organisations And Agreements
- Loading branch information
Showing
40 changed files
with
607 additions
and
50 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
2 changes: 1 addition & 1 deletion
2
src/SFA.DAS.Commitments.AddEpaToApprenticeships.WebJob.UnitTests/packages.config
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
13 changes: 13 additions & 0 deletions
13
src/SFA.DAS.Commitments.Api.Types/Commitment/CommitmentAgreement.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,13 @@ | ||
| ||
namespace SFA.DAS.Commitments.Api.Types.Commitment | ||
{ | ||
/// <summary> | ||
/// A subset of Commitment related to agreements | ||
/// </summary> | ||
public sealed class CommitmentAgreement | ||
{ | ||
public string Reference { get; set; } | ||
public string LegalEntityName { get; set; } | ||
public string AccountLegalEntityPublicHashedId { get; set; } | ||
} | ||
} |
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
48 changes: 48 additions & 0 deletions
48
...ents.Api.UnitTests/Controllers/ProviderControllerTests/WhenGettingCommitmentAgreements.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,48 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using System.Web.Http.Results; | ||
using Moq; | ||
using NUnit.Framework; | ||
using SFA.DAS.Commitments.Api.Controllers; | ||
using SFA.DAS.Commitments.Api.Orchestrators; | ||
using SFA.DAS.Commitments.Api.Types.Commitment; | ||
|
||
namespace SFA.DAS.Commitments.Api.UnitTests.Controllers.ProviderControllerTests | ||
{ | ||
[TestFixture] | ||
public class WhenGettingCommitmentAgreements | ||
{ | ||
private ProviderController _controller; | ||
private Mock<IProviderOrchestrator> _mockProviderOrchestrator; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
_mockProviderOrchestrator = new Mock<IProviderOrchestrator>(); | ||
|
||
_controller = new ProviderController(_mockProviderOrchestrator.Object, new Mock<IApprenticeshipsOrchestrator>().Object); | ||
} | ||
|
||
[Test] | ||
public async Task ThenCommitmentAgreementsReturnedFromOrchestratorAreReturned() | ||
{ | ||
// arrange | ||
const long providerId = 123L; | ||
|
||
var commitmentAgreements = new[] {new CommitmentAgreement {Reference = "ref", LegalEntityName = "len", AccountLegalEntityPublicHashedId = "aleHash"}}; | ||
|
||
_mockProviderOrchestrator.Setup(o => o.GetCommitmentAgreements(providerId)).ReturnsAsync(TestHelper.Clone(commitmentAgreements)); | ||
|
||
// act | ||
var result = await _controller.GetCommitmentAgreements(providerId); | ||
|
||
// assert | ||
Assert.IsNotNull(result); | ||
|
||
var contentResult = result as OkNegotiatedContentResult<IEnumerable<CommitmentAgreement>>; | ||
Assert.IsNotNull(contentResult); | ||
|
||
Assert.IsTrue(TestHelper.EnumerablesAreEqual(commitmentAgreements, contentResult.Content)); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...FA.DAS.Commitments.Api.UnitTests/Orchestrators/Mappers/WhenMappingACommitmentAgreement.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 Moq; | ||
using NUnit.Framework; | ||
using SFA.DAS.Commitments.Api.Orchestrators.Mappers; | ||
using SFA.DAS.Commitments.Application.Rules; | ||
|
||
namespace SFA.DAS.Commitments.Api.UnitTests.Orchestrators.Mappers | ||
{ | ||
[TestFixture] | ||
public class WhenMappingACommitmentAgreement | ||
{ | ||
private ICommitmentRules _rules; | ||
private CommitmentMapper _mapper; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
_rules = Mock.Of<ICommitmentRules>(); | ||
_mapper = new CommitmentMapper(_rules); | ||
} | ||
|
||
[Test] | ||
public void ThenMappingCompletesSuccessfully() | ||
{ | ||
const string reference = "COMREF", legalEntityName = "len", aleHash = "alehash"; | ||
|
||
var sourceDomainCommitmentAgreement = new Domain.Entities.CommitmentAgreement | ||
{ | ||
Reference = reference, | ||
LegalEntityName = legalEntityName, | ||
AccountLegalEntityPublicHashedId = aleHash | ||
}; | ||
|
||
var mappedTypesCommitmentAgreement = _mapper.Map(sourceDomainCommitmentAgreement); | ||
|
||
Assert.AreEqual(reference, mappedTypesCommitmentAgreement.Reference); | ||
Assert.AreEqual(legalEntityName, mappedTypesCommitmentAgreement.LegalEntityName); | ||
Assert.AreEqual(aleHash, mappedTypesCommitmentAgreement.AccountLegalEntityPublicHashedId); | ||
} | ||
} | ||
} |
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
60 changes: 60 additions & 0 deletions
60
...A.DAS.Commitments.Api.UnitTests/Orchestrators/Provider/WhenGettingCommitmentAgreements.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,60 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Moq; | ||
using NUnit.Framework; | ||
using SFA.DAS.Commitments.Api.Orchestrators; | ||
using SFA.DAS.Commitments.Api.Orchestrators.Mappers; | ||
using SFA.DAS.Commitments.Application.Queries.GetCommitmentAgreements; | ||
using SFA.DAS.Commitments.Domain.Entities; | ||
using SFA.DAS.Commitments.Domain.Interfaces; | ||
|
||
namespace SFA.DAS.Commitments.Api.UnitTests.Orchestrators.Provider | ||
{ | ||
[TestFixture] | ||
public class WhenGettingCommitmentAgreements : ProviderOrchestratorTestBase | ||
{ | ||
[Test] | ||
public async Task ThenResultIsMappedCommitmentAgreementsReturnedFromGetCommitmentAgreementsQueryHandler() | ||
{ | ||
const long providerId = 321L; | ||
|
||
MockMediator.Setup(m => m.SendAsync(It.IsAny<GetCommitmentAgreementsRequest>())) | ||
.ReturnsAsync(new GetCommitmentAgreementsResponse | ||
{ | ||
Data = new List<CommitmentAgreement> | ||
{ | ||
new CommitmentAgreement | ||
{ | ||
Reference = "ref", | ||
LegalEntityName = "len", | ||
AccountLegalEntityPublicHashedId = "aleHash" | ||
} | ||
} | ||
}); | ||
|
||
var mappedCommitmentAgreement = new Types.Commitment.CommitmentAgreement | ||
{ | ||
Reference = "mapped ref", | ||
LegalEntityName = "mapped len", | ||
AccountLegalEntityPublicHashedId = "mapped aleHash" | ||
}; | ||
|
||
var mockCommitmentMapper = new Mock<ICommitmentMapper>(); | ||
|
||
mockCommitmentMapper.Setup(m => m.Map(It.IsAny<Domain.Entities.CommitmentAgreement>())) | ||
.Returns(TestHelper.Clone(mappedCommitmentAgreement)); | ||
|
||
Orchestrator = new ProviderOrchestrator( | ||
MockMediator.Object, | ||
Mock.Of<ICommitmentsLogger>(), | ||
MockFacetMapper.Object, | ||
MockApprenticeshipFilter.Object, | ||
new ApprenticeshipMapper(), | ||
mockCommitmentMapper.Object); | ||
|
||
var result = await Orchestrator.GetCommitmentAgreements(providerId); | ||
|
||
Assert.IsTrue(TestHelper.EnumerablesAreEqual(new[] { mappedCommitmentAgreement }, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Collections.Generic; | ||
using KellermanSoftware.CompareNetObjects; | ||
using Newtonsoft.Json; | ||
|
||
namespace SFA.DAS.Commitments.Api.UnitTests | ||
{ | ||
public static class TestHelper | ||
{ | ||
public static T Clone<T>(T source) | ||
{ | ||
var serialized = JsonConvert.SerializeObject(source); | ||
return JsonConvert.DeserializeObject<T>(serialized); | ||
} | ||
|
||
public static bool EnumerablesAreEqual<T>(IEnumerable<T> expected, IEnumerable<T> actual) | ||
{ | ||
return new CompareLogic(new ComparisonConfig { IgnoreObjectTypes = true }) | ||
.Compare(expected, actual).AreEqual; | ||
} | ||
} | ||
} |
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.