public async Task ValidateVerificationCode_ShouldReturn_SuccessMessage_If_Phone_CountryCode_VerificationCode_Are_Valid() { // Arrange var verifyServiceMock = new Mock <IPhoneVerificationService>(); var param = new ValidatePhoneVerificationDTO() { PhoneNumber = TEST_NUMBER, CountryCode = TEST_COUNTRY_CODE, VerificationCode = TEST_VERIFICATION_CODE }; verifyServiceMock.Setup(vs => vs.ValidateVerificationCodeAsync(param.CountryCode, param.PhoneNumber, param.VerificationCode)).ReturnsAsync(Result.Ok(true)); // Act var controller = new PhoneVerificationController(verifyServiceMock.Object); var actualResult = await controller.ValidateVerificationCode(param); // Assert Assert.IsAssignableFrom <OkObjectResult>(actualResult); var contentResult = actualResult as OkObjectResult; Assert.AreEqual(Status200, contentResult.StatusCode.Value); Assert.IsAssignableFrom <string>(contentResult.Value); var actualValue = contentResult.Value as string; Assert.AreEqual(Constants.PhoneVerifyMessages.Verification_Completed, actualValue); }
public async Task GenerateVerificationCode_ShouldReturn_ErrorMessage_If_Phone_Or_Country_Is_Invalid(GeneratePhoneVerificationDTO param) { // Arrange var verifyServiceMock = new Mock <IPhoneVerificationService>(); verifyServiceMock.Setup(vs => vs.GenerateVerificationCodeAsync(param.CountryCode, param.PhoneNumber)).ReturnsAsync(Result.Fail <bool>(Constants.PhoneVerifyMessages.Country_Phone_Invalid)); // Act var controller = new PhoneVerificationController(verifyServiceMock.Object); var actualResult = await controller.GenerateVerificationCode(param); // Assert Assert.IsAssignableFrom <BadRequestObjectResult>(actualResult); var contentResult = actualResult as BadRequestObjectResult; Assert.AreEqual(Status400, contentResult.StatusCode.Value); Assert.IsAssignableFrom <string>(contentResult.Value); var actualValue = contentResult.Value as string; }