public async Task TestContatoWsAsyncRegisterContactData() { User user = new User(); var gen = new GeneratorOtp() { NumberOfChar = 8 }; gen.GenerateOtp(); user.Id = gen.SmsCode; user.Age = 60; user.Name = "teste " + user.Id; user.DddPhoneNumber = user.Id; user.AcceptTerms = true; user.CreateRecord = DateTime.Now; var result = await contactWs.RegisterContact(user); Assert.NotNull(result); Assert.Contains(result.Age.ToString(), user.Age.ToString()); Assert.Contains(result.Name, user.Name); Assert.Contains(result.Phone, user.DddPhoneNumber); Assert.Contains(result.Id, user.Id); }
public void TestOTP() { var otp = new GeneratorOtp(); otp.GenerateOtp(); Assert.Equal(expected: otp.SmsCode.Length, 6); }
public void TestOTPRandom() { var otp = new GeneratorOtp(); otp.GenerateOtp(); var otp1 = new GeneratorOtp(); otp1.GenerateOtp(); Assert.True(otp.SmsCode != otp1.SmsCode); }
private async Task SendSMSAsync() { if (IsRunningSms == false) { IsBusy = true; //Gera o número randomico var gerador = new GeneratorOtp(); gerador.GenerateOtp(); CodigoSms = gerador.SmsCode; //Envia o sms ClientSms cSms = new ClientSms(); var phoneNumber = "55" + (NumeroTelefone.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "")); var result = cSms.SendSMSAsync(phoneNumber, CodigoSms); VisibleErro = true; if (result != null) { //Sucesso if (Enviado) { //A partir do segundo envio Erro = "Código enviado com sucesso!"; IsBusy = false; var thread = new Thread(() => CountSec()); thread.Start(); } else { //Primeira vez que envia o sms VisibleErro = false; Erro = ""; lbReenviarColor = "#219653"; } IsBusy = false; Enviado = true; } else { // Erro no envio Erro = "Problema no envio do SMS!"; IsBusy = false; lbReenviarColor = "#219653"; } } }