Skip to content

Commit

Permalink
Merge pull request #855 from SkillsFundingAgency/CON-956-Store-Hashed…
Browse files Browse the repository at this point in the history
…AccountLegalEntityId

CON-956 populated account legal entity hash id in employer edit info …
  • Loading branch information
narendranogothu authored Dec 10, 2019
2 parents 743e478 + 01bac99 commit ad39473
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Esfa.Recruit.Employer.UnitTests.Recruit.Vacancies.Client.Infrastructure.Mappings
{
public class LegalEntityMapperTests
public class WhenMappingAddress
{
[Fact]
public void ShouldMapFullFivePartAddress()
Expand Down
Original file line number Diff line number Diff line change
@@ -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<LegalEntityViewModel>()
.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.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<AgreementViewModel>()
.With(x => x.Status, EmployerAgreementStatus.Signed)
.Create();
var expected = fixture
.Build<LegalEntityViewModel>()
.With(x => x.Address, "Cheylesmore House, 5 Quinton Rd, Coventry, CV1 2WT")
.With( x => x.Agreements, new List<AgreementViewModel>{ agreementViewModel })
.Create();

// Act
var actual = LegalEntityMapper.MapFromAccountApiLegalEntity(expected);

// Assert
actual.HasLegalEntityAgreement.Should().BeTrue();
}
}
}
1 change: 1 addition & 0 deletions src/Employer/UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.11.0" />
<PackageReference Include="FluentAssertions" Version="5.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="Moq" Version="4.13.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down

0 comments on commit ad39473

Please sign in to comment.