public async Task Arrange() { _apprenticeshipIncentiveData = new Fixture().CreateMany <ApprenticeshipIncentiveModel>(); _hashedAccountId = Guid.NewGuid().ToString(); _hashedLegalEntityId = Guid.NewGuid().ToString(); _organisationName = Guid.NewGuid().ToString(); _mockLegalEntitiesService = new Mock <ILegalEntitiesService>(); _mockLegalEntitiesService .Setup(m => m.Get(_hashedAccountId, _hashedLegalEntityId)) .ReturnsAsync(new LegalEntityModel() { Name = _organisationName }); _mockApprenticeshipIncentiveService = new Mock <IApprenticeshipIncentiveService>(); _mockApprenticeshipIncentiveService .Setup(m => m.GetList(_hashedAccountId, _hashedLegalEntityId)) .ReturnsAsync(_apprenticeshipIncentiveData); _sut = new Web.Controllers.CancelController(_mockApprenticeshipIncentiveService.Object, _mockLegalEntitiesService.Object) { TempData = new TempDataDictionary(new DefaultHttpContext(), Mock.Of <ITempDataProvider>()) }; _result = await _sut.CancelApplication(_hashedAccountId, _hashedLegalEntityId); _model = ((ViewResult)_result).Model as SelectApprenticeshipsViewModel; }
public async Task Then_should_display_a_list_of_apprentices_with_checked_ones_selected() { foreach (var _apprenticeshipIncentive in _apprenticeshipIncentiveData) { _apprenticeshipIncentive.Selected = false; } _mockApprenticeshipIncentiveService .Setup(m => m.GetList(_hashedAccountId, _hashedLegalEntityId)) .ReturnsAsync(_apprenticeshipIncentiveData); _sut.TempData["selected"] = new string[] { _apprenticeshipIncentiveData.First().Id }; _result = await _sut.CancelApplication(_hashedAccountId, _hashedLegalEntityId); _model = ((ViewResult)_result).Model as SelectApprenticeshipsViewModel; _model.ApprenticeshipIncentives.Single(a => a.Id == _apprenticeshipIncentiveData.First().Id).Selected.Should().BeTrue(); _model.ApprenticeshipIncentives.Any(a => a.Id != _apprenticeshipIncentiveData.First().Id&& a.Selected).Should().BeFalse(); _sut.TempData.Should().BeEmpty(); }