Beispiel #1
0
 public void SendKeysToOnlyNumbers(string value)
 {
     try
     {
         OnlyNumbers.SendKeys(value);
     }catch (NoSuchElementException e)
     {
         Console.WriteLine(e.Message);
     }
 }
Beispiel #2
0
        public bool IsValidPhone(string phone)
        {
            if (String.IsNullOrWhiteSpace(phone))
            {
                return(false);
            }

            string numericPhone = OnlyNumbers.FetchOnlyNumbers(phone);

            return(IsValidLength(numericPhone) && IsValidCode(numericPhone) && IsValidNumberStart(numericPhone));
        }
Beispiel #3
0
        public bool IsValidCep(string cep)
        {
            if (String.IsNullOrWhiteSpace(cep))
            {
                return(false);
            }

            string numericCep = OnlyNumbers.FetchOnlyNumbers(cep);

            return(IsValidLength(numericCep));
        }
Beispiel #4
0
        public string Format(string cnpj)
        {
            if (string.IsNullOrWhiteSpace(cnpj))
            {
                return(string.Empty);
            }

            string numericCNPJ = OnlyNumbers.FetchOnlyNumbers(cnpj);

            return(Convert.ToUInt64(numericCNPJ.Substring(0, Math.Min(Constants.CNPJ_LENGHT, numericCNPJ.Length))).ToString(Constants.CNPJ_FORMAT_PATTERN));
        }
Beispiel #5
0
        public bool IsValidCpf(string cpf)
        {
            if (String.IsNullOrWhiteSpace(cpf))
            {
                return(false);
            }

            string numericCpf = OnlyNumbers.FetchOnlyNumbers(cpf);

            return(IsValidLength(numericCpf) && !BelongsToBlacklist(numericCpf) && IsValidChecksum(numericCpf));
        }
Beispiel #6
0
        public string Format(string cpf)
        {
            if (string.IsNullOrWhiteSpace(cpf))
            {
                return(string.Empty);
            }

            string numericCPF = OnlyNumbers.FetchOnlyNumbers(cpf);

            return(Convert.ToUInt64(numericCPF.Substring(0, Math.Min(Constants.CPF_LENGTH, numericCPF.Length))).ToString(Constants.CPF_FORMAT_PATTERN));
        }
Beispiel #7
0
        public bool IsValidBoleto(string digitableLine)
        {
            if (string.IsNullOrWhiteSpace(digitableLine))
            {
                return(false);
            }

            digitableLine = OnlyNumbers.FetchOnlyNumbers(digitableLine);

            return(IsValidLength(digitableLine) &&
                   validateDigitableLinePartials(digitableLine) &&
                   Mod11(ParseDigitableLine(digitableLine).Remove(4, 1)).ToString().Equals(Convert.ToString(ParseDigitableLine(digitableLine)[4])));
        }
Beispiel #8
0
        public static string Formatar(string cep)
        {
            var unformattedCEP = new OnlyNumbers(cep).ToString();

            if (unformattedCEP.Length != 8)
            {
                return(cep);
            }

            string pattern = @"{0:00\.000\-000}";

            return(String.Format(pattern, Convert.ToUInt64(unformattedCEP)));
        }
Beispiel #9
0
        public void ReturnFalseGivenValueOf1()
        {
            var result = OnlyNumbers.FetchOnlyNumbers("032.721.340-00");

            Assert.Equal("03272134000", result);
        }
Beispiel #10
0
        public void TestShouldReturnNumbers()
        {
            OnlyNumbers only = new OnlyNumbers("1$2@3aA-4%5!6/7?8#9*0 ");

            Assert.AreEqual("1234567890", only.ToString());
        }
Beispiel #11
0
        public void TestShouldReturnEmpty()
        {
            OnlyNumbers only = new OnlyNumbers("");

            Assert.AreEqual("", only.ToString());
        }