Skip to content

Commit

Permalink
Merge pull request #209 from SkillsFundingAgency/CON-3569_FullNameDis…
Browse files Browse the repository at this point in the history
…playedOnApprenticeNameChange

CON-3569 Added fix to model mapper
  • Loading branch information
Najamuddin-Muhammad authored Jun 1, 2021
2 parents 369ad22 + 6b41576 commit e6f72fe
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,38 @@ public async Task OriginalApprenticeship_TrainingName_IsMapped()
Assert.AreEqual(fixture.ApprenticeshipUpdate.TrainingName, viewModel.ApprenticeshipUpdates.CourseName);
}

[Test]
public async Task If_FirstName_Only_Updated_Map_FirstName_From_OriginalApprenticeship()
{
fixture.GetApprenticeshipUpdatesResponses.ApprenticeshipUpdates.First().LastName = null;

var viewModel = await fixture.Map();

Assert.AreEqual(fixture.ApprenticeshipUpdate.FirstName, viewModel.ApprenticeshipUpdates.FirstName);
Assert.AreEqual(fixture.GetApprenticeshipResponse.LastName, viewModel.ApprenticeshipUpdates.LastName);
}

[Test]
public async Task If_LastName_Only_Updated_Map_FirstName_From_OriginalApprenticeship()
{
fixture.GetApprenticeshipUpdatesResponses.ApprenticeshipUpdates.First().FirstName = null;

var viewModel = await fixture.Map();

Assert.AreEqual(fixture.ApprenticeshipUpdate.LastName, viewModel.ApprenticeshipUpdates.LastName);
Assert.AreEqual(fixture.GetApprenticeshipResponse.FirstName, viewModel.ApprenticeshipUpdates.FirstName);
}

[Test]
public async Task If_BothNames_Updated_Map_BothNames_From_Update()
{
var viewModel = await fixture.Map();

Assert.AreEqual(fixture.ApprenticeshipUpdate.FirstName, viewModel.ApprenticeshipUpdates.FirstName);
Assert.AreEqual(fixture.ApprenticeshipUpdate.LastName, viewModel.ApprenticeshipUpdates.LastName);
}


public class ReviewApprenticeshipUpdatesRequestToViewModelMapperTestsFixture
{
public ReviewApprenticeshipUpdatesRequestToViewModelMapper Mapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public async Task<ReviewApprenticeshipUpdatesRequestViewModel> Map(ReviewApprent
{
var update = updates.ApprenticeshipUpdates.First();

if (!string.IsNullOrWhiteSpace(update.FirstName + update.LastName))
{
update.FirstName = string.IsNullOrWhiteSpace(update.FirstName) ? apprenticeship.FirstName : update.FirstName;
update.LastName = string.IsNullOrWhiteSpace(update.LastName) ? apprenticeship.LastName : update.LastName;
}

var vm = new ReviewApprenticeshipUpdatesRequestViewModel
{
AccountHashedId = source.AccountHashedId,
Expand Down

0 comments on commit e6f72fe

Please sign in to comment.