public void Setup() { _otpAlgorithm = MockRepository.GenerateMock<IOTPAlgorithm>(); _movingFactorAlgorithm = MockRepository.GenerateMock<IMovingFactorAlgorithm>(); _errorFactory = MockRepository.GenerateMock<IErrorFactory>(); _otpConfiguration = new OTPConfiguration { OTPExpiryInSeconds = 31, NumberOfDigitsInOTP = 6, PrivateKey = "as9121jd623ms23h232k3" }; _otpService = new OTPService(_otpAlgorithm, _movingFactorAlgorithm, _errorFactory, _otpConfiguration); _invalidRequestError = new OTPError { Code = "InvalidRequest", Description = "Please check your request and try again." }; _errorFactory.Stub(factory => factory.GetInvalidRequestError()).Return(_invalidRequestError); _genericError = new OTPError { Code = "InternalError", Description = "Something went wrong, please try again later." }; _errorFactory.Stub(factory => factory.GetErrorForException(null)).IgnoreArguments().Return(_genericError); }
public OTPService(IOTPAlgorithm otpAlgorithm, IMovingFactorAlgorithm movingFactorAlgorithm, IErrorFactory errorFactory, OTPConfiguration otpConfiguration) { _otpAlgorithm = otpAlgorithm; _movingFactorAlgorithm = movingFactorAlgorithm; _errorFactory = errorFactory; _otpConfiguration = otpConfiguration; }
public void Setup() { _otpConfiguration = new OTPConfiguration { OTPExpiryInSeconds = 30, NumberOfDigitsInOTP = 6, PrivateKey = "as9121jd623ms23h232k3" }; _currentTimeFunction = MockRepository.GenerateMock<Func<DateTime>>(); _expiryBasedMovingFactorAlgorithm = new ExpiryBasedMovingFactorAlgorithm(_otpConfiguration, _currentTimeFunction); }