Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cv 588 Select New employer #119

Open
wants to merge 46 commits into
base: CV-587_InformPage
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b4f19f2
Merge branch 'CV-587_InformPage' into CV-588-Change-Employer
Feb 19, 2020
a271771
CV-588 Change Of Employer
Feb 20, 2020
6f1fb67
CV-588 Added more test.
Feb 21, 2020
67b3319
CV-588 Code Refactoring.
Feb 24, 2020
5d1298d
Merge branch 'master' into CV-588-Change-Employer
Feb 24, 2020
948449a
Merge branch 'CV-587_InformPage' into CV-588-Change-Employer
Feb 24, 2020
57517ff
CV-588 Code refactoring.
Feb 24, 2020
1ef7abf
Cv-588 Cohort Refactoring
Feb 24, 2020
e83af2f
CV-588 Code Refactoring.
Feb 24, 2020
1230c77
cv-588
Feb 24, 2020
5d20081
CV-588 Code review changes.
Feb 25, 2020
46216c7
Confirm employer WIP
chrisfoster76 Feb 26, 2020
6b94477
Merge branch 'CV-588-Change-Employer' into CV-589-Confirm-Employer
Feb 26, 2020
fc7b512
Merge branch 'master' into CV-588-Change-Employer
Feb 27, 2020
217dd73
Merge branch 'CV-856_ChangeEmployerLink' into CV-588-Change-Employer
Feb 27, 2020
f218315
Merge branch 'CV-587_InformPage' into CV-588-Change-Employer
Feb 27, 2020
80450bc
CV-589 Adding views
Feb 27, 2020
abb6a87
CV-589 Added tests and validator
Feb 27, 2020
ba10cfa
Merge branch 'CV-587_InformPage' into CV-588-Change-Employer
Pauljgraham Feb 28, 2020
3076ccf
CV-589 Fix url
Feb 28, 2020
6ed9855
Merge branch 'CV-587_InformPage' into CV-588-Change-Employer
Pauljgraham Feb 28, 2020
0b850bc
CV-589 More tests.
Feb 28, 2020
37e3ee7
removed extra title after merge
Pauljgraham Feb 28, 2020
294fe71
CV-589 Removed commented code
Feb 28, 2020
c79cb70
CV-589 Renamed folder
Feb 28, 2020
2509810
CV-589 Refactoring
Feb 28, 2020
14085de
CV-589
Feb 28, 2020
a713cb9
Merge branch 'master' into CV-589-Confirm-Employer
Mar 2, 2020
95f9170
Merge branch 'master' into CV-589-Reactoring-Changes
Mar 2, 2020
00e010a
Merge branch 'CV-588-Change-Employer' into CV-589-Confirm-Employer
Mar 2, 2020
5011e70
Merge branch 'CV-588-Change-Employer' into CV-589-Reactoring-Changes
Mar 2, 2020
66e1076
Merge branch 'CV-589-Confirm-Employer' into CV-589-Reactoring-Changes
Mar 2, 2020
db5b2c4
Test Review: added id's to apprentice details v2
AkshayBanifatsyevichChugh Mar 2, 2020
6869ebc
CV-589 Tech review changes.
Mar 2, 2020
a1d1bd3
CV-589 Test fix
Mar 2, 2020
323caaa
Merge pull request #127 from SkillsFundingAgency/CV-589-Reactoring-Ch…
hkf-tech Mar 2, 2020
36ba3fd
CV-589 Test file name changed.
Mar 2, 2020
d15a35c
CV-589 Tech review changes.
Mar 2, 2020
829c4a5
Merge pull request #128 from SkillsFundingAgency/CV-583-DataLock-Tria…
Najamuddin-Muhammad Mar 2, 2020
04dabc7
Merge branch 'master' into CV-589-Confirm-Employer
Mar 3, 2020
af5535f
CV-635 Footer Changes.
Mar 4, 2020
ab27751
CV-635 Updated the shared UI package.
Mar 5, 2020
f2ff117
Merge pull request #130 from SkillsFundingAgency/CV-635-Footer
hkf-tech Mar 5, 2020
c63c2ed
CV-586 Bug Fix
Mar 6, 2020
7d85785
CV-589
Mar 6, 2020
c251197
Merge pull request #126 from SkillsFundingAgency/CV-589-Confirm-Employer
Najamuddin-Muhammad Mar 6, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using Moq;
using NUnit.Framework;
using SFA.DAS.CommitmentsV2.Shared.Interfaces;
using SFA.DAS.ProviderCommitments.Web.Controllers;
using AutoFixture;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using SFA.DAS.ProviderCommitments.Web.Models.Apprentice;

namespace SFA.DAS.ProviderCommitments.Web.UnitTests.Controllers.ApprenticeControllerTests
{
[TestFixture]
public class WhenGettingConfirmEmployer
{
[Test]
public async Task ThenCallsModelMapper()
{
var fixture = new GetConfirmEmployerFixture();

await fixture.Act();

fixture.VerifyMapperWasCalled();
}

[Test]
public async Task ThenReturnsView()
{
var fixture = new GetConfirmEmployerFixture();

var result = await fixture.Act();

result.VerifyReturnsViewModel().WithModel<ConfirmEmployerViewModel>();
}
}

public class GetConfirmEmployerFixture
{
public ApprenticeController Sut { get; set; }

private readonly Mock<IModelMapper> _modelMapperMock;
private readonly ConfirmEmployerViewModel _viewModel;
private readonly ConfirmEmployerRequest _request;
private readonly long _providerId;

public GetConfirmEmployerFixture()
{
var fixture = new Fixture();
_request = new ConfirmEmployerRequest { ProviderId = _providerId, EmployerAccountLegalEntityPublicHashedId = "XYZ" };
_modelMapperMock = new Mock<IModelMapper>();
_viewModel = fixture.Create<ConfirmEmployerViewModel>();
_providerId = 123;

_modelMapperMock
.Setup(x => x.Map<ConfirmEmployerViewModel>(_request))
.ReturnsAsync(_viewModel);

Sut = new ApprenticeController(_modelMapperMock.Object);
}

public GetConfirmEmployerFixture WithModelStateErrors()
{
Sut.ControllerContext.ModelState.AddModelError("TestError", "Test Error");
return this;
}

public void VerifyMapperWasCalled()
{
_modelMapperMock.Verify(x => x.Map<ConfirmEmployerViewModel>(_request));
}

public async Task<IActionResult> Act() => await Sut.ConfirmEmployer(_request);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using Microsoft.AspNetCore.Mvc;
using Moq;
using NUnit.Framework;
using SFA.DAS.CommitmentsV2.Shared.Interfaces;
using SFA.DAS.ProviderCommitments.Web.Controllers;
using SFA.DAS.ProviderCommitments.Web.Models.Apprentice;
using SFA.DAS.ProviderCommitments.Web.Models.Shared;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace SFA.DAS.ProviderCommitments.Web.UnitTests.Controllers.ApprenticesControllerTests
{
[TestFixture]
public class WhenGettingSelectEmployer
{
[Test]
public async Task ThenCallsModelMapper()
{
var fixture = new SelectEmployerFixture();

await fixture.Act();

fixture.VerifyMapperWasCalled();
}

[Test]
public async Task ThenReturnsView()
{
var fixture = new SelectEmployerFixture();

var result = await fixture.Act() as ViewResult;

Assert.NotNull(result);
Assert.AreEqual(typeof(SelectEmployerViewModel), result.Model.GetType());
}
}

public class SelectEmployerFixture
{
public ApprenticeController Sut { get; set; }

private readonly Mock<IModelMapper> _modelMapperMock;
private readonly SelectEmployerViewModel _viewModel;
private readonly SelectEmployerRequest _request;

public SelectEmployerFixture()
{
_request = new SelectEmployerRequest { ProviderId = 1, ApprenticeshipId = 1 };
_modelMapperMock = new Mock<IModelMapper>();
_viewModel = new SelectEmployerViewModel
{
AccountProviderLegalEntities = new List<AccountProviderLegalEntityViewModel>(),
};

_modelMapperMock
.Setup(x => x.Map<SelectEmployerViewModel>(_request))
.ReturnsAsync(_viewModel);

Sut = new ApprenticeController(_modelMapperMock.Object);
}

public SelectEmployerFixture WithModelStateErrors()
{
Sut.ControllerContext.ModelState.AddModelError("TestError", "Test Error");
return this;
}

public void VerifyMapperWasCalled()
{
_modelMapperMock.Verify(x => x.Map<SelectEmployerViewModel>(_request));
}

public async Task<IActionResult> Act() => await Sut.SelectEmployer(_request);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using Microsoft.AspNetCore.Mvc;
using Moq;
using NUnit.Framework;
using SFA.DAS.CommitmentsV2.Shared.Interfaces;
using SFA.DAS.ProviderCommitments.Web.Controllers;
using System.Threading.Tasks;
using SFA.DAS.ProviderCommitments.Web.Models.Apprentice;

namespace SFA.DAS.ProviderCommitments.Web.UnitTests.Controllers.ApprenticeControllerTests
{
[TestFixture]
public class WhenIPostConfirmEmployer
{
[Test]
public async Task PostConfirmEmployerViewModel_WithValidModel_WithConfirmFalse_ShouldRedirectToSelectEmployer()
{
var fixture = new PostConfirmEmployerFixture()
.WithConfirmFalse();

var result = await fixture.Act();
result.VerifyReturnsRedirectToActionResult().WithActionName("SelectEmployer");
}

[Test]
public async Task PostConfirmEmployerViewModel_WithValidModel_WithConfirmTrue_RedirectToDates()
{
var fixture = new PostConfirmEmployerFixture()
.WithConfirmTrue();

var result = await fixture.Act();
result.VerifyReturnsRedirectToActionResult().WithActionName("Dates");
}
}

public class PostConfirmEmployerFixture
{
public ApprenticeController Sut { get; set; }

public string RedirectUrl;
private readonly ConfirmEmployerViewModel _viewModel;
private readonly long _providerId;

public PostConfirmEmployerFixture()
{
_providerId = 123;
_viewModel = new ConfirmEmployerViewModel { ProviderId = _providerId, EmployerAccountLegalEntityPublicHashedId = "XYZ" , ApprenticeshipHashedId = "ABC"};
Sut = new ApprenticeController(Mock.Of<IModelMapper>());
}

public PostConfirmEmployerFixture WithConfirmFalse()
{
_viewModel.Confirm = false;
return this;
}

public PostConfirmEmployerFixture WithConfirmTrue()
{
_viewModel.Confirm = true;
return this;
}

public async Task<IActionResult> Act() => Sut.ConfirmEmployer(_viewModel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
using NUnit.Framework;
using SFA.DAS.CommitmentsV2.Shared.Interfaces;
using SFA.DAS.ProviderCommitments.Web.Controllers;
using SFA.DAS.ProviderCommitments.Web.Models;
using SFA.DAS.ProviderCommitments.Web.Requests;
using SFA.DAS.ProviderUrlHelper;
using AutoFixture;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using SFA.DAS.CommitmentsV2.Api.Client;
using SFA.DAS.ProviderCommitments.Web.Models.Cohort;

namespace SFA.DAS.ProviderCommitments.Web.UnitTests.Controllers.CohortControllerTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
using SFA.DAS.CommitmentsV2.Api.Client;
using SFA.DAS.CommitmentsV2.Shared.Interfaces;
using SFA.DAS.ProviderCommitments.Web.Controllers;
using SFA.DAS.ProviderCommitments.Web.Models;
using SFA.DAS.ProviderCommitments.Web.Requests;
using SFA.DAS.ProviderCommitments.Web.Models.Cohort;
using SFA.DAS.ProviderCommitments.Web.Models.Shared;
using SFA.DAS.ProviderUrlHelper;

namespace SFA.DAS.ProviderCommitments.Web.UnitTests.Controllers.CohortControllerTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Threading.Tasks;
using System.Threading;
using SFA.DAS.CommitmentsV2.Api.Client;
using SFA.DAS.ProviderCommitments.Web.Models.Cohort;

namespace SFA.DAS.ProviderCommitments.Web.UnitTests.Controllers.CohortControllerTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using SFA.DAS.ProviderCommitments.Queries.GetTrainingCourses;
using SFA.DAS.ProviderCommitments.Web.Controllers;
using SFA.DAS.ProviderCommitments.Web.Models;
using SFA.DAS.ProviderCommitments.Web.Requests;
using SFA.DAS.ProviderUrlHelper;
using RedirectResult = Microsoft.AspNetCore.Mvc.RedirectResult;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using AutoFixture;
using Moq;
using NUnit.Framework;
using SFA.DAS.CommitmentsV2.Api.Client;
using SFA.DAS.ProviderCommitments.Web.Mappers.Apprentice;
using SFA.DAS.ProviderCommitments.Web.Models.Apprentice;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace SFA.DAS.ProviderCommitments.Web.UnitTests.Mappers.Apprentice
{
[TestFixture]
public class ConfirmEmployerViewModelMapperTests
{
private ConfirmEmployerViewModelMapper _mapper;
private ConfirmEmployerRequest _source;
private Func<Task<ConfirmEmployerViewModel>> _act;
private CommitmentsV2.Api.Types.Responses.AccountLegalEntityResponse _accountLegalEntityResponse;

[SetUp]
public void Arrange()
{
var fixture = new Fixture();
_accountLegalEntityResponse = fixture.Create<CommitmentsV2.Api.Types.Responses.AccountLegalEntityResponse>();
_source = fixture.Create<ConfirmEmployerRequest>();
var icommitmentApiClient = new Mock<ICommitmentsApiClient>();
icommitmentApiClient.Setup(x => x.GetLegalEntity(It.IsAny<long>(), It.IsAny<CancellationToken>())).ReturnsAsync(_accountLegalEntityResponse);

_mapper = new ConfirmEmployerViewModelMapper(icommitmentApiClient.Object);

_act = async () => await _mapper.Map(_source);
}

[Test]
public async Task ThenEmployerAccountLegalEntityPublicHashedIdIsMappedCorrectly()
{
var result = await _act();
Assert.AreEqual(_source.EmployerAccountLegalEntityPublicHashedId, result.EmployerAccountLegalEntityPublicHashedId);
}

[Test]
public async Task ThenEmployerAccountNameIsMappedCorrectly()
{
var result = await _act();
Assert.AreEqual(_accountLegalEntityResponse.AccountName, result.EmployerAccountName);
}

[Test]
public async Task ThenEmployerAccountLegalEntityNameIsMappedCorrectly()
{
var result = await _act();
Assert.AreEqual(_accountLegalEntityResponse.LegalEntityName, result.EmployerAccountLegalEntityName);
}

[Test]
public async Task ThenProviderIdMappedCorrectly()
{
var result = await _act();
Assert.AreEqual(_source.ProviderId, result.ProviderId);
}
}
}
Loading