public void VerifyMobileTest(VerifyMobileState verifyMobileState, string accountMediatorCode, string pageMessage, UserMessageLevel userMessageLevel)
        {
            //Arrange
            //const VerifyMobileState verifyMobileState = VerifyMobileState.Ok;
            var verifyMobileViewModel = new VerifyMobileViewModelBuilder().PhoneNumber(MobileNumber).VerifyMobileState(verifyMobileState).MobileVerificationCode(ValidVerificationCode).Build();

            var verifyMobileViewModelServerValidatorMock = new Mock <VerifyMobileViewModelServerValidator>();

            verifyMobileViewModelServerValidatorMock.Setup(x => x.Validate(It.IsAny <VerifyMobileViewModel>())).Returns(new ValidationResult());

            var accountProviderMock = new Mock <IAccountProvider>();

            accountProviderMock.Setup(x => x.VerifyMobile(It.IsAny <Guid>(), It.IsAny <VerifyMobileViewModel>())).Returns(verifyMobileViewModel);

            var accountMediator = new AccountMediatorBuilder().With(accountProviderMock.Object).With(verifyMobileViewModelServerValidatorMock).Build();

            //Act
            var response = accountMediator.VerifyMobile(Guid.NewGuid(), new VerifyMobileViewModel()
            {
                PhoneNumber = MobileNumber, VerifyMobileCode = ValidVerificationCode
            });

            //Assert
            response.Code.Should().Be(accountMediatorCode);
            response.Message.Text.Should().Be(pageMessage);
            response.Message.Level.Should().Be(userMessageLevel);
        }
        public void ValidationErrorTest()
        {
            //Arrange
            const VerifyMobileState verifyMobileState = VerifyMobileState.VerifyMobileCodeInvalid;
            var v = new ValidationResult();

            v.Errors.Add(new ValidationFailure("VerifyMobileCode", "Length should be less than 4 digits"));

            var verifyMobileViewModel = new VerifyMobileViewModelBuilder().PhoneNumber(MobileNumber).VerifyMobileState(verifyMobileState).MobileVerificationCode(InvalidVerificationCode).Build();

            //todo: nice to have to convert into a builder class
            var verifyMobileViewModelServerValidatorMock = new Mock <VerifyMobileViewModelServerValidator>();

            verifyMobileViewModelServerValidatorMock.Setup(x => x.Validate(It.IsAny <VerifyMobileViewModel>())).Returns(v);

            var accountProviderMock = new Mock <IAccountProvider>();

            accountProviderMock.Setup(x => x.VerifyMobile(It.IsAny <Guid>(), It.IsAny <VerifyMobileViewModel>())).Returns(verifyMobileViewModel);

            var accountMediator = new AccountMediatorBuilder().With(accountProviderMock.Object).With(verifyMobileViewModelServerValidatorMock).Build();

            //Act
            var response = accountMediator.VerifyMobile(Guid.NewGuid(), new VerifyMobileViewModel()
            {
                PhoneNumber = MobileNumber, VerifyMobileCode = ValidVerificationCode
            });

            //Assert
            response.Code.Should().Be(AccountMediatorCodes.VerifyMobile.ValidationError);
            response.ValidationResult.Should().NotBeNull();
        }
Ejemplo n.º 3
0
        public void GivenValidCode_DefaultViewModelIsReturned()
        {
            //Arrange
            var candidateId   = Guid.NewGuid();
            var candidateMock =
                new CandidateBuilder(candidateId)
                .EnableApplicationStatusChangeAlertsViaText(true)
                .PhoneNumber(PhoneNumber)
                .VerifiedMobile(false)
                .Build();

            var candidateServiceMock = new Mock <ICandidateService>();

            candidateServiceMock.Setup(cs => cs.GetCandidate(candidateId)).Returns(candidateMock);
            candidateServiceMock.Setup(cs => cs.SendMobileVerificationCode(candidateMock));

            var viewModel = new VerifyMobileViewModelBuilder().PhoneNumber(PhoneNumber).Build();
            var provider  = new AccountProviderBuilder().With(candidateServiceMock).Build();

            //Act
            var result = provider.SendMobileVerificationCode(candidateId, viewModel);

            //Assert
            result.Status.Should().Be(VerifyMobileState.Ok);
            result.HasError().Should().BeFalse();
            result.ViewModelMessage.Should().BeNullOrEmpty();
        }
Ejemplo n.º 4
0
        public void GivenEntityStateError_ThenValidViewModelIsReturned(string errorCode, VerifyMobileState verifyMobileState)
        {
            //Arrange
            var candidateId   = Guid.NewGuid();
            var candidateMock =
                new CandidateBuilder(candidateId)
                .EnableApplicationStatusChangeAlertsViaText(true)
                .PhoneNumber(PhoneNumber)
                .VerifiedMobile(false)
                .Build();

            var candidateServiceMock = new Mock <ICandidateService>();

            candidateServiceMock.Setup(cs => cs.GetCandidate(candidateId)).Returns(candidateMock);
            candidateServiceMock.Setup(cs => cs.SendMobileVerificationCode(candidateMock)).Throws(new CustomException(errorCode));

            var viewModel = new VerifyMobileViewModelBuilder().PhoneNumber(PhoneNumber).Build();
            var provider  = new AccountProviderBuilder().With(candidateServiceMock).Build();

            //Act
            var result = provider.SendMobileVerificationCode(candidateId, viewModel);

            //Assert
            result.Status.Should().Be(verifyMobileState);
            result.HasError().Should().BeTrue();
            result.ViewModelMessage.Should().NotBeNull();
        }
Ejemplo n.º 5
0
        public void US616_AC5_VerifyMobilePageElements()
        {
            var viewModel = new VerifyMobileViewModelBuilder().Build();

            var result = new VerifyMobileViewBuilder().With(viewModel).Render();

            var phoneNumber      = result.GetElementbyId("phoneNumber");
            var verifyMobileCode = result.GetElementbyId("VerifyMobileCode");

            phoneNumber.Should().NotBeNull();
            verifyMobileCode.Should().NotBeNull();
        }
Ejemplo n.º 6
0
        public void ShowFindTraineeshipLink(bool shouldShow)
        {
            var viewModel = new VerifyMobileViewModelBuilder().ShowTraineeshipsLink(shouldShow).ShowTraineeshipsPrompt(false).Build();

            var result = new VerifyMobileViewBuilder().With(viewModel).Render();

            var findTraineeshipLink = result.GetElementbyId("find-traineeship-link");

            if (shouldShow)
            {
                findTraineeshipLink.Should().NotBeNull();
            }
            else
            {
                findTraineeshipLink.Should().BeNull();
            }
        }
Ejemplo n.º 7
0
        public void GivenValidCode_DefaultViewModelIsReturned()
        {
            //Arrange
            var candidateId          = Guid.NewGuid();
            var candidateServiceMock = new Mock <ICandidateService>();

            candidateServiceMock.Setup(cs => cs.VerifyMobileCode(candidateId, VerificationCode));;
            var viewModel = new VerifyMobileViewModelBuilder().PhoneNumber(PhoneNumber).MobileVerificationCode(VerificationCode).Build();
            var provider  = new AccountProviderBuilder().With(candidateServiceMock).Build();

            //Act
            var result = provider.VerifyMobile(candidateId, viewModel);

            //Assert
            result.Status.Should().Be(VerifyMobileState.Ok);
            result.HasError().Should().BeFalse();
            result.ViewModelMessage.Should().BeNullOrEmpty();
        }
Ejemplo n.º 8
0
        public void ResendTest(VerifyMobileState verifyMobileState, string accountMediatorCode, string pageMessage, UserMessageLevel userMessageLevel)
        {
            //Arrange
            var verifyMobileViewModel = new VerifyMobileViewModelBuilder().PhoneNumber(MobileNumber).VerifyMobileState(verifyMobileState).Build();

            var accountProviderMock = new Mock <IAccountProvider>();

            accountProviderMock.Setup(x => x.SendMobileVerificationCode(It.IsAny <Guid>(), It.IsAny <VerifyMobileViewModel>())).Returns(verifyMobileViewModel);

            var accountMediator = new AccountMediatorBuilder().With(accountProviderMock.Object).Build();

            //Act
            var response = accountMediator.Resend(Guid.NewGuid(), new VerifyMobileViewModel()
            {
                PhoneNumber = MobileNumber
            });

            //Assert
            response.Code.Should().Be(accountMediatorCode);
            response.Message.Text.Should().Be(pageMessage);
            response.Message.Level.Should().Be(userMessageLevel);
        }