-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into FAT2-294_fat_decomi…
…ssioning
- Loading branch information
Showing
96 changed files
with
3,809 additions
and
194 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...eb.UnitTests/Controllers/ApprenticeControllerTests/ApprenticeControllerTestFixtureBase.cs
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using AutoFixture; | ||
using Microsoft.Extensions.Logging; | ||
using Moq; | ||
using SFA.DAS.Authorization.Services; | ||
using SFA.DAS.CommitmentsV2.Api.Client; | ||
using SFA.DAS.CommitmentsV2.Shared.Interfaces; | ||
using SFA.DAS.EmployerCommitmentsV2.Web.Controllers; | ||
using SFA.DAS.EmployerCommitmentsV2.Web.Models.Apprentice; | ||
using SFA.DAS.EmployerUrlHelper; | ||
|
||
namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Controllers.ApprenticeControllerTests | ||
{ | ||
public class ApprenticeControllerTestFixtureBase | ||
{ | ||
protected Fixture _autoFixture; | ||
|
||
protected readonly Mock<IModelMapper> _mockMapper; | ||
protected readonly Mock<ICommitmentsApiClient> _mockCommitmentsApiClient; | ||
protected readonly Mock<IAuthorizationService> _mockAuthorizationService; | ||
|
||
protected readonly ApprenticeController _controller; | ||
|
||
public ApprenticeControllerTestFixtureBase() | ||
{ | ||
_autoFixture = new Fixture(); | ||
|
||
_mockMapper = new Mock<IModelMapper>(); | ||
_mockCommitmentsApiClient = new Mock<ICommitmentsApiClient>(); | ||
_mockAuthorizationService = new Mock<IAuthorizationService>(); | ||
|
||
_controller = new ApprenticeController(_mockMapper.Object, | ||
Mock.Of<ICookieStorageService<IndexRequest>>(), | ||
_mockCommitmentsApiClient.Object, | ||
Mock.Of<ILinkGenerator>(), | ||
Mock.Of<ILogger<ApprenticeController>>(), | ||
_mockAuthorizationService.Object); | ||
} | ||
} | ||
} |
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
62 changes: 62 additions & 0 deletions
62
...UnitTests/Controllers/ApprenticeControllerTests/WhenCallingGetWhatIsTheNewEndDateTests.cs
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using AutoFixture; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
using Moq; | ||
using NUnit.Framework; | ||
using SFA.DAS.Authorization.Services; | ||
using SFA.DAS.CommitmentsV2.Api.Client; | ||
using SFA.DAS.CommitmentsV2.Shared.Interfaces; | ||
using SFA.DAS.EmployerCommitmentsV2.Web.Controllers; | ||
using SFA.DAS.EmployerCommitmentsV2.Web.Models.Apprentice; | ||
using SFA.DAS.EmployerUrlHelper; | ||
using System.Threading.Tasks; | ||
|
||
namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Controllers.ApprenticeControllerTests | ||
{ | ||
public class WhenCallingGetWhatIsTheNewEndDateTests | ||
{ | ||
WhenCallingGetWhatIsTheNewEndDateTestsFixture _fixture; | ||
|
||
[SetUp] | ||
public void Arrange() | ||
{ | ||
_fixture = new WhenCallingGetWhatIsTheNewEndDateTestsFixture(); | ||
} | ||
|
||
[Test] | ||
public async Task ThenTheCorrectViewIsReturned() | ||
{ | ||
var result = await _fixture.WhatIsTheNewEndDate(); | ||
|
||
_fixture.VerifyViewModel(result as ViewResult); | ||
} | ||
} | ||
|
||
public class WhenCallingGetWhatIsTheNewEndDateTestsFixture : ApprenticeControllerTestFixtureBase | ||
{ | ||
private readonly ChangeOfProviderRequest _request; | ||
private readonly WhatIsTheNewEndDateViewModel _viewModel; | ||
|
||
public WhenCallingGetWhatIsTheNewEndDateTestsFixture() : base() | ||
{ | ||
_request = _autoFixture.Create<ChangeOfProviderRequest>(); | ||
_viewModel = _autoFixture.Create<WhatIsTheNewEndDateViewModel>(); | ||
|
||
_mockMapper.Setup(m => m.Map<WhatIsTheNewEndDateViewModel>(_request)) | ||
.ReturnsAsync(_viewModel); | ||
} | ||
|
||
public async Task<IActionResult> WhatIsTheNewEndDate() | ||
{ | ||
return await _controller.WhatIsTheNewEndDate(_request); | ||
} | ||
|
||
public void VerifyViewModel(ViewResult viewResult) | ||
{ | ||
var viewModel = viewResult.Model as WhatIsTheNewEndDateViewModel; | ||
|
||
Assert.IsInstanceOf<WhatIsTheNewEndDateViewModel>(viewModel); | ||
Assert.AreEqual(_viewModel, viewModel); | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...b.UnitTests/Controllers/ApprenticeControllerTests/WhenCallingGetWhatIsTheNewPriceTests.cs
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using AutoFixture; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
using Moq; | ||
using NUnit.Framework; | ||
using SFA.DAS.Authorization.Services; | ||
using SFA.DAS.CommitmentsV2.Api.Client; | ||
using SFA.DAS.CommitmentsV2.Shared.Interfaces; | ||
using SFA.DAS.EmployerCommitmentsV2.Web.Controllers; | ||
using SFA.DAS.EmployerCommitmentsV2.Web.Models.Apprentice; | ||
using SFA.DAS.EmployerUrlHelper; | ||
using System.Threading.Tasks; | ||
|
||
namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Controllers.ApprenticeControllerTests | ||
{ | ||
public class WhenCallingGetWhatIsTheNewPriceTests | ||
{ | ||
WhenCallingGetWhatIsTheNewPriceTestsFixture _fixture; | ||
|
||
[SetUp] | ||
public void Arrange() | ||
{ | ||
_fixture = new WhenCallingGetWhatIsTheNewPriceTestsFixture(); | ||
} | ||
|
||
[Test] | ||
public async Task ThenTheCorrectViewIsReturned() | ||
{ | ||
var result = await _fixture.WhatIsTheNewPrice(); | ||
|
||
_fixture.VerifyViewModel(result as ViewResult); | ||
} | ||
} | ||
|
||
public class WhenCallingGetWhatIsTheNewPriceTestsFixture : ApprenticeControllerTestFixtureBase | ||
{ | ||
private readonly ChangeOfProviderRequest _request; | ||
private readonly WhatIsTheNewPriceViewModel _viewModel; | ||
|
||
|
||
public WhenCallingGetWhatIsTheNewPriceTestsFixture() : base() | ||
{ | ||
_request = _autoFixture.Create<ChangeOfProviderRequest>(); | ||
_viewModel = _autoFixture.Create<WhatIsTheNewPriceViewModel>(); | ||
|
||
_mockMapper.Setup(m => m.Map<WhatIsTheNewPriceViewModel>(_request)) | ||
.ReturnsAsync(_viewModel); | ||
} | ||
|
||
public async Task<IActionResult> WhatIsTheNewPrice() | ||
{ | ||
return await _controller.WhatIsTheNewPrice(_request); | ||
} | ||
|
||
public void VerifyViewModel(ViewResult viewResult) | ||
{ | ||
var viewModel = viewResult.Model as WhatIsTheNewPriceViewModel; | ||
|
||
Assert.IsInstanceOf<WhatIsTheNewPriceViewModel>(viewModel); | ||
Assert.AreEqual(_viewModel, viewModel); | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...tTests/Controllers/ApprenticeControllerTests/WhenCallingGetWhoWillEnterTheDetailsTests.cs
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using AutoFixture; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Moq; | ||
using NUnit.Framework; | ||
using SFA.DAS.EmployerCommitmentsV2.Web.Models.Apprentice; | ||
using System.Threading.Tasks; | ||
|
||
namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Controllers.ApprenticeControllerTests | ||
{ | ||
public class WhenCallingGetWhoWillEnterTheDetailsTests | ||
{ | ||
WhenCallingGetWhoWillEnterTheDetailsTestsFixture _fixture; | ||
|
||
[SetUp] | ||
public void Arrange() | ||
{ | ||
_fixture = new WhenCallingGetWhoWillEnterTheDetailsTestsFixture(); | ||
} | ||
|
||
[Test] | ||
public async Task ThenTheCorrectViewIsReturned() | ||
{ | ||
var result = await _fixture.WhoWillEnterTheDetails(); | ||
|
||
_fixture.VerifyViewModel(result as ViewResult); | ||
} | ||
} | ||
|
||
public class WhenCallingGetWhoWillEnterTheDetailsTestsFixture : ApprenticeControllerTestFixtureBase | ||
{ | ||
private readonly ChangeOfProviderRequest _request; | ||
private readonly WhoWillEnterTheDetailsViewModel _viewModel; | ||
|
||
public WhenCallingGetWhoWillEnterTheDetailsTestsFixture() : base() | ||
{ | ||
_request = _autoFixture.Create<ChangeOfProviderRequest>(); | ||
_viewModel = _autoFixture.Create<WhoWillEnterTheDetailsViewModel>(); | ||
|
||
_mockMapper.Setup(m => m.Map<WhoWillEnterTheDetailsViewModel>(_request)) | ||
.ReturnsAsync(_viewModel); | ||
} | ||
|
||
public async Task<IActionResult> WhoWillEnterTheDetails() | ||
{ | ||
return await _controller.WhoWillEnterTheDetails(_request); | ||
} | ||
|
||
public void VerifyViewModel(ViewResult viewResult) | ||
{ | ||
var viewModel = viewResult.Model as WhoWillEnterTheDetailsViewModel; | ||
|
||
Assert.IsInstanceOf<WhoWillEnterTheDetailsViewModel>(viewModel); | ||
Assert.AreEqual(_viewModel, viewModel); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.