Ejemplo n.º 1
0
        public async Task Then_should_show_error_if_no_selection_is_made()
        {
            var request = new SelectApprenticeshipsRequest()
            {
                AccountLegalEntityId = _hashedLegalEntityId,
                AccountId            = _hashedAccountId
            };
            var result = _sut.SelectApprenticeships(request);

            var viewResult = await result as ViewResult;

            viewResult.Should().NotBeNull();
            _sut.ViewData.ModelState.IsValid.Should().BeFalse();
            _sut.ViewData.ModelState.Single(x => x.Key == _model.FirstCheckboxId).Value.Errors
            .Should().Contain(x => x.ErrorMessage == SelectApprenticeshipsViewModel.SelectApprenticeshipsMessage);
            viewResult?.ViewName.Should().BeNullOrEmpty();
        }
Ejemplo n.º 2
0
        public async Task Arrange()
        {
            _applicationId       = Guid.NewGuid();
            _apprenticeData      = new Fixture().CreateMany <ApprenticeshipModel>();
            _hashedAccountId     = Guid.NewGuid().ToString();
            _hashedLegalEntityId = Guid.NewGuid().ToString();

            _apprenticesServiceMock = new Mock <IApprenticesService>();
            _apprenticesServiceMock
            .Setup(x => x.Get(It.Is <ApprenticesQuery>(q =>
                                                       q.AccountId == _hashedAccountId && q.AccountLegalEntityId == _hashedLegalEntityId)))
            .ReturnsAsync(_apprenticeData);

            _applicationServiceMock = new Mock <IApplicationService>();
            _applicationServiceMock
            .Setup(x => x.Create(_hashedAccountId, _hashedLegalEntityId, It.IsAny <IEnumerable <string> >()))
            .ReturnsAsync(_applicationId);

            _sut = new Web.Controllers.ApplyApprenticeshipsController(_apprenticesServiceMock.Object, _applicationServiceMock.Object, Mock.Of <ILegalEntitiesService>());

            _result = await _sut.SelectApprenticeships(_hashedAccountId, _hashedLegalEntityId);

            _model = ((ViewResult)_result).Model as SelectApprenticeshipsViewModel;
        }