public void ErrorTest() { var candidate = new Candidate { RegistrationDetails = new RegistrationDetails { AcceptedTermsAndConditionsVersion = "1" } }; var candidateServiceProviderMock = new Mock <ICandidateServiceProvider>(); candidateServiceProviderMock.Setup(x => x.GetCandidate(It.IsAny <Guid>())).Returns(candidate); var configurationServiceMock = new Mock <IConfigurationService>(); configurationServiceMock.Setup(x => x.Get <CommonWebConfiguration>()) .Returns(new CommonWebConfiguration() { TermsAndConditionsVersion = "1.1" }); candidateServiceProviderMock.Setup(x => x.AcceptTermsAndConditions(It.IsAny <Guid>(), It.IsAny <string>())).Returns(false); var accountMediator = new AccountMediatorBuilder().With(candidateServiceProviderMock).With(configurationServiceMock).Build(); var response = accountMediator.AcceptTermsAndConditions(Guid.NewGuid()); response.Code.Should().Be(AccountMediatorCodes.AcceptTermsAndConditions.ErrorAccepting); }
public void ExceptionTest() { var candidateServiceProviderMock = new Mock <ICandidateServiceProvider>(); candidateServiceProviderMock.Setup(x => x.GetCandidate(It.IsAny <Guid>())).Throws <Exception>(); var configurationManagerMock = new Mock <IConfigurationManager>(); configurationManagerMock.Setup(x => x.GetAppSetting <string>("TermsAndConditionsVersion")).Returns("1.1"); var accountMediator = new AccountMediatorBuilder().With(candidateServiceProviderMock).With(configurationManagerMock).Build(); var response = accountMediator.AcceptTermsAndConditions(Guid.NewGuid()); response.Code.Should().Be(AccountMediatorCodes.AcceptTermsAndConditions.ErrorAccepting); }
public void AlreadyAcceptedTest() { var candidate = new Candidate { RegistrationDetails = new RegistrationDetails { AcceptedTermsAndConditionsVersion = "1.1" } }; var candidateServiceProviderMock = new Mock <ICandidateServiceProvider>(); candidateServiceProviderMock.Setup(x => x.GetCandidate(It.IsAny <Guid>())).Returns(candidate); var configurationManagerMock = new Mock <IConfigurationManager>(); configurationManagerMock.Setup(x => x.GetAppSetting <string>("TermsAndConditionsVersion")).Returns("1.1"); candidateServiceProviderMock.Setup(x => x.AcceptTermsAndConditions(It.IsAny <Guid>(), It.IsAny <string>())).Returns(true); var accountMediator = new AccountMediatorBuilder().With(candidateServiceProviderMock).With(configurationManagerMock).Build(); var response = accountMediator.AcceptTermsAndConditions(Guid.NewGuid()); response.Code.Should().Be(AccountMediatorCodes.AcceptTermsAndConditions.AlreadyAccepted); }