-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/SkillsFundingAgency/das-e…
…mployerapprenticeshipsservice into CON-1488-Employer-unsubscribe-alert-summary-notification-email
- Loading branch information
Showing
12 changed files
with
74 additions
and
16 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
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
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
using SFA.DAS.EmployerAccounts.Data; | ||
using SFA.DAS.EmployerAccounts.Mappings; | ||
using SFA.DAS.EmployerAccounts.Models.Account; | ||
using SFA.DAS.EmployerAccounts.Models.UserProfile; | ||
using SFA.DAS.EmployerAccounts.Queries.GetLegalEntity; | ||
using SFA.DAS.EmployerAccounts.TestCommon; | ||
using FluentTestFixture = SFA.DAS.Testing.FluentTestFixture; | ||
|
@@ -26,13 +27,24 @@ public Task Handle_WhenGettingLegalEntity_ThenShouldReturnLegalEntity() | |
return RunAsync(f => f.Handle(), (f, r) => r.Should().NotBeNull() | ||
.And.Match<GetLegalEntityResponse>(r2 => | ||
r2.LegalEntity.LegalEntityId == f.LegalEntity.Id && | ||
r2.LegalEntity.Agreements.Count == 2 && | ||
r2.LegalEntity.Agreements.Count == 3 && | ||
r2.LegalEntity.Agreements.Any(a => a.TemplateVersionNumber == 1 && a.Status == Api.Types.EmployerAgreementStatus.Signed) && | ||
r2.LegalEntity.Agreements.Any(a => a.TemplateVersionNumber == 2 && a.Status == Api.Types.EmployerAgreementStatus.Pending) && | ||
r2.LegalEntity.Agreements.Any(a => a.TemplateVersionNumber == 2 && a.Status == Api.Types.EmployerAgreementStatus.Signed) && | ||
r2.LegalEntity.Agreements.Any(a => a.TemplateVersionNumber == 3 && a.Status == Api.Types.EmployerAgreementStatus.Pending) && | ||
r2.LegalEntity.AgreementStatus == Api.Types.EmployerAgreementStatus.Pending && | ||
r2.LegalEntity.Agreements.Any(a => a.AgreementType == f.LegalEntity.AccountLegalEntities.First().Agreements.First().Template.AgreementType) | ||
)); | ||
} | ||
|
||
[Test] | ||
public async Task Handle_WhenGettingLegalEntity_ThenShouldReturnTheCorrectEmailOfUserWhoSignedTheAgreement() | ||
{ | ||
var f = new GetLegalEntityQueryTestsFixture(); | ||
var result = await f.Handle(); | ||
|
||
result.LegalEntity.Agreements.First(a => a.TemplateVersionNumber == 1 && a.Status == Api.Types.EmployerAgreementStatus.Signed).SignedByEmail.Should().Be(f.UserB.Email); | ||
result.LegalEntity.Agreements.First(a => a.TemplateVersionNumber == 2 && a.Status == Api.Types.EmployerAgreementStatus.Signed).SignedByEmail.Should().Be(f.UserA.Email); | ||
} | ||
} | ||
|
||
public class GetLegalEntityQueryTestsFixture : FluentTestFixture | ||
|
@@ -47,6 +59,10 @@ public class GetLegalEntityQueryTestsFixture : FluentTestFixture | |
public List<LegalEntity> LegalEntities { get; set; } | ||
public List<AccountLegalEntity> AccountLegalEntities { get; set; } | ||
public DbSetStub<AccountLegalEntity> AccountLegalEntitiesDbSet { get; set; } | ||
public User UserA { get; set; } | ||
public User UserB { get; set; } | ||
public List<User> Users { get; set; } | ||
public DbSetStub<User> UsersDbSet { get; set; } | ||
|
||
public GetLegalEntityQueryTestsFixture() | ||
{ | ||
|
@@ -64,17 +80,24 @@ public GetLegalEntityQueryTestsFixture() | |
AccountLegalEntities = new List<AccountLegalEntity>(); | ||
AccountLegalEntitiesDbSet = new DbSetStub<AccountLegalEntity>(AccountLegalEntities); | ||
|
||
UserA = new User { Id = 1, Email = "[email protected]"}; | ||
UserB = new User { Id = 2, Email = "[email protected]"}; | ||
Users = new List<User> { UserA, UserB }; | ||
UsersDbSet = new DbSetStub<User>(Users); | ||
|
||
Db.Setup(d => d.LegalEntities).Returns(LegalEntitiesDbSet); | ||
Db.Setup(d => d.AccountLegalEntities).Returns(AccountLegalEntitiesDbSet); | ||
Db.Setup(d => d.Users).Returns(UsersDbSet); | ||
|
||
Handler = new GetLegalEntityQueryHandler(new Lazy<EmployerAccountsDbContext>(() => Db.Object), ConfigurationProvider); | ||
|
||
SetAccount() | ||
.SetLegalEntity() | ||
.SetLegalAccountLegalEntity() | ||
.AddLegalEntityAgreement(1, EmployerAccounts.Models.EmployerAgreement.EmployerAgreementStatus.Removed) | ||
.AddLegalEntityAgreement(1, EmployerAccounts.Models.EmployerAgreement.EmployerAgreementStatus.Signed) | ||
.AddLegalEntityAgreement(2, EmployerAccounts.Models.EmployerAgreement.EmployerAgreementStatus.Pending) | ||
.AddLegalEntityAgreement(1, EmployerAccounts.Models.EmployerAgreement.EmployerAgreementStatus.Removed, UserA.Id) | ||
.AddLegalEntityAgreement(1, EmployerAccounts.Models.EmployerAgreement.EmployerAgreementStatus.Signed, UserB.Id) | ||
.AddLegalEntityAgreement(2, EmployerAccounts.Models.EmployerAgreement.EmployerAgreementStatus.Signed, UserA.Id) | ||
.AddLegalEntityAgreement(3, EmployerAccounts.Models.EmployerAgreement.EmployerAgreementStatus.Pending) | ||
.EvaluateSignedAndPendingAgreementIdsForAllAccountLegalEntities(); | ||
} | ||
|
||
|
@@ -153,7 +176,7 @@ private GetLegalEntityQueryTestsFixture SetLegalAccountLegalEntity() | |
return this; | ||
} | ||
|
||
private GetLegalEntityQueryTestsFixture AddLegalEntityAgreement(int versionNumber, EmployerAccounts.Models.EmployerAgreement.EmployerAgreementStatus status) | ||
private GetLegalEntityQueryTestsFixture AddLegalEntityAgreement(int versionNumber, EmployerAccounts.Models.EmployerAgreement.EmployerAgreementStatus status, long? signedUserId = null) | ||
{ | ||
var newAgreement = new EmployerAgreement | ||
{ | ||
|
@@ -162,7 +185,8 @@ private GetLegalEntityQueryTestsFixture AddLegalEntityAgreement(int versionNumbe | |
VersionNumber = versionNumber, | ||
AgreementType = AgreementType.Levy | ||
}, | ||
StatusId = status | ||
StatusId = status, | ||
SignedById = signedUserId | ||
}; | ||
|
||
newAgreement.AccountLegalEntity = 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
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