diff --git a/src/Employer/UnitTests/Recruit.Vacancies.Client/Infrastructure/Mappings/LegalEntityMapperTests.cs b/src/Employer/UnitTests/Recruit.Vacancies.Client/Infrastructure/Mappings/LegalEntityMapperTests/WhenMappingAddress.cs similarity index 98% rename from src/Employer/UnitTests/Recruit.Vacancies.Client/Infrastructure/Mappings/LegalEntityMapperTests.cs rename to src/Employer/UnitTests/Recruit.Vacancies.Client/Infrastructure/Mappings/LegalEntityMapperTests/WhenMappingAddress.cs index 999c8f7d5a..63fdb3e83e 100644 --- a/src/Employer/UnitTests/Recruit.Vacancies.Client/Infrastructure/Mappings/LegalEntityMapperTests.cs +++ b/src/Employer/UnitTests/Recruit.Vacancies.Client/Infrastructure/Mappings/LegalEntityMapperTests/WhenMappingAddress.cs @@ -4,7 +4,7 @@ namespace Esfa.Recruit.Employer.UnitTests.Recruit.Vacancies.Client.Infrastructure.Mappings { - public class LegalEntityMapperTests + public class WhenMappingAddress { [Fact] public void ShouldMapFullFivePartAddress() diff --git a/src/Employer/UnitTests/Recruit.Vacancies.Client/Infrastructure/Mappings/LegalEntityMapperTests/WhenMappingLegalEntity.cs b/src/Employer/UnitTests/Recruit.Vacancies.Client/Infrastructure/Mappings/LegalEntityMapperTests/WhenMappingLegalEntity.cs new file mode 100644 index 0000000000..8c0de5b511 --- /dev/null +++ b/src/Employer/UnitTests/Recruit.Vacancies.Client/Infrastructure/Mappings/LegalEntityMapperTests/WhenMappingLegalEntity.cs @@ -0,0 +1,56 @@ +using SFA.DAS.EAS.Account.Api.Types; +using Xunit; +using AutoFixture; +using FluentAssertions; +using Esfa.Recruit.Vacancies.Client.Infrastructure.Services.EmployerAccount; +using System; +using System.Collections.Generic; + +namespace UnitTests.Recruit.Vacancies.Client.Infrastructure.Mappings.LegalEntityMapperTests +{ + public class WhenMappingLegalEntity + { + [Fact] + public void ThenReturnsCorrectlyPolulatedLegalEntity() + { + // Arrange + var fixture = new Fixture(); + var expected = fixture + .Build() + .With(x => x.Address, "Cheylesmore House, 5 Quinton Rd, Coventry, CV1 2WT") + .With( x => x.Agreements, new List()) + .Create(); + + // Act + var actual = LegalEntityMapper.MapFromAccountApiLegalEntity(expected); + + // Assert + actual.LegalEntityId.Should().Be(expected.LegalEntityId); + actual.AccountLegalEntityPublicHashedId.Should().Be(expected.AccountLegalEntityPublicHashedId); + actual.Name.Should().Be(expected.Name); + actual.HasLegalEntityAgreement.Should().BeFalse(); + } + + [Fact] + public void ThenSetsHasLegalEntityAgreementToTrue() + { + // Arrange + var fixture = new Fixture(); + var agreementViewModel = fixture + .Build() + .With(x => x.Status, EmployerAgreementStatus.Signed) + .Create(); + var expected = fixture + .Build() + .With(x => x.Address, "Cheylesmore House, 5 Quinton Rd, Coventry, CV1 2WT") + .With( x => x.Agreements, new List{ agreementViewModel }) + .Create(); + + // Act + var actual = LegalEntityMapper.MapFromAccountApiLegalEntity(expected); + + // Assert + actual.HasLegalEntityAgreement.Should().BeTrue(); + } + } +} \ No newline at end of file diff --git a/src/Employer/UnitTests/UnitTests.csproj b/src/Employer/UnitTests/UnitTests.csproj index 5f4611a604..a6d4940807 100644 --- a/src/Employer/UnitTests/UnitTests.csproj +++ b/src/Employer/UnitTests/UnitTests.csproj @@ -8,6 +8,7 @@ false + diff --git a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/EmployerAccount/LegalEntityMapper.cs b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/EmployerAccount/LegalEntityMapper.cs index 6b61586ef5..e28e3b969f 100644 --- a/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/EmployerAccount/LegalEntityMapper.cs +++ b/src/Shared/Recruit.Vacancies.Client/Infrastructure/Services/EmployerAccount/LegalEntityMapper.cs @@ -13,6 +13,7 @@ public static LegalEntity MapFromAccountApiLegalEntity(LegalEntityViewModel data return new LegalEntity { LegalEntityId = data.LegalEntityId, + AccountLegalEntityPublicHashedId = data.AccountLegalEntityPublicHashedId, Name = data.Name, Address = MapFromAddressLine(data.Address), HasLegalEntityAgreement = data.Agreements.Any(a =>