Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into FAT2-294_fat_decomi…
Browse files Browse the repository at this point in the history
…ssioning
  • Loading branch information
dashton82 committed Feb 2, 2021
2 parents 34fc7c4 + 0647a1c commit 83bcfad
Show file tree
Hide file tree
Showing 96 changed files with 3,809 additions and 194 deletions.
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand Down Expand Up @@ -55,7 +56,8 @@ public WhenCallingChangeProviderRequestedConfirmationPageTestsFixture()
Mock.Of<ICookieStorageService<IndexRequest>>(),
Mock.Of<ICommitmentsApiClient>(),
Mock.Of<ILinkGenerator>(),
Mock.Of<ILogger<ApprenticeController>>());
Mock.Of<ILogger<ApprenticeController>>(),
Mock.Of<IAuthorizationService>());
}

public async Task<IActionResult> ChangeProviderRequested()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
using AutoFixture;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Moq;
using NUnit.Framework;
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;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Controllers.ApprenticeControllerTests
Expand All @@ -34,30 +26,18 @@ public async Task ThenViewIsReturned()
}
}

public class WhenCallingGetEnterNewTrainingProviderTestsFixture
public class WhenCallingGetEnterNewTrainingProviderTestsFixture : ApprenticeControllerTestFixtureBase
{
private readonly Mock<IModelMapper> _mockMapper;
private readonly ChangeOfProviderRequest _request;
private readonly EnterNewTrainingProviderViewModel _viewModel;

private EnterNewTrainingProviderRequest _request;
private EnterNewTrainingProviderViewModel _viewModel;

private ApprenticeController _controller;

public WhenCallingGetEnterNewTrainingProviderTestsFixture()
public WhenCallingGetEnterNewTrainingProviderTestsFixture() : base()
{
var autoFixture = new Fixture();
_request = autoFixture.Create<EnterNewTrainingProviderRequest>();
_viewModel = autoFixture.Create<EnterNewTrainingProviderViewModel>();
_request = _autoFixture.Create<ChangeOfProviderRequest>();
_viewModel = _autoFixture.Create<EnterNewTrainingProviderViewModel>();

_mockMapper = new Mock<IModelMapper>();
_mockMapper.Setup(m => m.Map<EnterNewTrainingProviderViewModel>(_request))
.ReturnsAsync(_viewModel);

_controller = new ApprenticeController(_mockMapper.Object,
Mock.Of<ICookieStorageService<IndexRequest>>(),
Mock.Of<ICommitmentsApiClient>(),
Mock.Of<ILinkGenerator>(),
Mock.Of<ILogger<ApprenticeController>>());
}

public async Task<IActionResult> EnterNewTrainingProvider()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using AutoFixture;
using AutoFixture.NUnit3;
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 SFA.DAS.Testing.AutoFixture;
using System.Threading.Tasks;

namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Controllers.ApprenticeControllerTests
Expand Down Expand Up @@ -56,7 +55,8 @@ public WhenCallingGetSendRequestNewTrainingProviderTestsFixture()
Mock.Of<ICookieStorageService<IndexRequest>>(),
Mock.Of<ICommitmentsApiClient>(),
Mock.Of<ILinkGenerator>(),
Mock.Of<ILogger<ApprenticeController>>());
Mock.Of<ILogger<ApprenticeController>>(),
Mock.Of<IAuthorizationService>());
}

public async Task<IActionResult> SendRequestNewTrainingProvider()
Expand Down
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);
}
}
}
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);
}
}
}
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
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;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Controllers.ApprenticeControllerTests
Expand Down Expand Up @@ -57,7 +55,8 @@ public WhenCallingTheViewChangesPageTestsFixture()
Mock.Of<ICookieStorageService<IndexRequest>>(),
Mock.Of<ICommitmentsApiClient>(),
Mock.Of<ILinkGenerator>(),
Mock.Of<ILogger<ApprenticeController>>());
Mock.Of<ILogger<ApprenticeController>>(),
Mock.Of<IAuthorizationService>());
}

public async Task<IActionResult> ViewChanges()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
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;
Expand All @@ -21,7 +22,12 @@ public void Arrange()
_mockCommitmentsApiClient = new Mock<ICommitmentsApiClient>();
_mockLinkGenerator = new Mock<ILinkGenerator>();

_controller = new ApprenticeController(_mockModelMapper.Object, _mockCookieStorageService.Object, _mockCommitmentsApiClient.Object, _mockLinkGenerator.Object, Mock.Of<ILogger<ApprenticeController>>());
_controller = new ApprenticeController(_mockModelMapper.Object,
_mockCookieStorageService.Object,
_mockCommitmentsApiClient.Object,
_mockLinkGenerator.Object,
Mock.Of<ILogger<ApprenticeController>>(),
Mock.Of<IAuthorizationService>());
}

[Test, MoqAutoData]
Expand Down
Loading

0 comments on commit 83bcfad

Please sign in to comment.