public void OtpGenerator_ValidUserIdAndDate_SuccessfullyGeneratedOtp(string userId, DateTime date, string expected) { // Arrange IOtpGenerator otpGenerator = new OtpGenerator(); // Act var result = otpGenerator.GenerateOtp(userId, date); // Assert Assert.Equal(expected, result); }
public void OtpGenerator_ValidUserIdAndDate_SuccessfullyCheckedRemainingSeconds(string userId, DateTime date, long expected) { // Arrange IOtpGenerator otpGenerator = new OtpGenerator(); var otp = otpGenerator.GenerateOtp(userId, date); // Act var result = otpGenerator.GetOtpRemainingSeconds(userId, otp); // Assert Assert.Equal(expected, result); }
public void OtpGenerator_ValidUserIdAndInvalidDate_GenerateEmptyOtp() { // Arrange IOtpGenerator otpGenerator = new OtpGenerator(); var userId = "1233445"; var date = new DateTime(1969, 1, 1); // Act var result = otpGenerator.GenerateOtp(userId, date); // Assert Assert.Equal(string.Empty, result); }
public void OtpGenerator_ValidUserIdAndDateUtcNow_RemainingSecondsGreaterThanZeroAndSmallerOrEqualThanThirty() { // Arrange IOtpGenerator otpGenerator = new OtpGenerator(); var userId = "1233445"; var date = DateTime.UtcNow; var otp = otpGenerator.GenerateOtp(userId, date); // Act var result = otpGenerator.GetOtpRemainingSeconds(userId, otp); // Assert Assert.True(result > 0 && result <= 30); }