Exemple #1
0
        public void ReturnsTrueWithValidValue()
        {
            var    attr     = new PhoneNumberAttribute();
            string value    = "+33123456798";
            bool   expected = true;
            bool   result   = attr.IsValid(value);

            Assert.AreEqual(expected, result);
        }
Exemple #2
0
        public void ReturnsTrueWithEmptyValue()
        {
            var    attr     = new PhoneNumberAttribute();
            string value    = string.Empty;
            bool   expected = true;
            bool   result   = attr.IsValid(value);

            Assert.AreEqual(expected, result);
        }
		public void PhoneNumbersCountry()
		{
			var sut = new PhoneNumberAttribute("NZ");

			Assert.IsTrue(sut.IsValid("")); //empty
			Assert.IsTrue(sut.IsValid((string)null)); //null
			Assert.IsTrue(sut.IsValid(1)); //not string
			Assert.IsTrue(sut.IsValid("+64 21 000 0000")); //valid international number
			Assert.IsTrue(sut.IsValid("+64210000000")); //valid number no spaces
			Assert.IsTrue(sut.IsValid("021 000 0000")); //valid number as country code specified
			Assert.IsTrue(sut.IsValid("021-00 000 00")); //valid number weird spaces and dashes

			Assert.IsFalse(sut.IsValid("021 000 00")); //invalid number as too short
			Assert.IsFalse(sut.IsValid("021 000 000000")); //invalid number as too long
		}
        public void PhoneNumbersCountry()
        {
            var sut = new PhoneNumberAttribute("NZ");

            Assert.IsTrue(sut.IsValid(""));                //empty
            Assert.IsTrue(sut.IsValid((string)null));      //null
            Assert.IsTrue(sut.IsValid(1));                 //not string
            Assert.IsTrue(sut.IsValid("+64 21 000 0000")); //valid international number
            Assert.IsTrue(sut.IsValid("+64210000000"));    //valid number no spaces
            Assert.IsTrue(sut.IsValid("021 000 0000"));    //valid number as country code specified
            Assert.IsTrue(sut.IsValid("021-00 000 00"));   //valid number weird spaces and dashes

            Assert.IsFalse(sut.IsValid("021 000 00"));     //invalid number as too short
            Assert.IsFalse(sut.IsValid("021 000 000000")); //invalid number as too long
        }