public void NormalizePhone2() { var n = DataEntryUtils.NormalizeUSPhone("2224415"); Console.WriteLine(n); Assert.AreEqual("(???) 222-4415", n); }
public void NormalizePhone9() { var n = DataEntryUtils.NormalizeUSPhone("555.222.4415"); Console.WriteLine(n); Aver.AreEqual("(555) 222-4415", n); }
public void NormalizePhone3() { var n = DataEntryUtils.NormalizeUSPhone(" +38 067 2148899 "); Console.WriteLine(n); Assert.AreEqual("+38 067 2148899", n); }
public void NormalizePhone12() { var n = DataEntryUtils.NormalizeUSPhone("5552224415ext.123"); n.See(); Aver.AreEqual("(555) 222-4415x123", n); }
public void NormalizePhone8() { var n = DataEntryUtils.NormalizeUSPhone("555-222-4415 X 2014"); Console.WriteLine(n); Aver.AreEqual("(555) 222-4415x2014", n); }
public void NormalizePhone10() { var n = DataEntryUtils.NormalizeUSPhone("555-222-4415"); n.See(); Aver.AreEqual("(555) 222-4415", n); }
public void NormalizePhone3() { var n = DataEntryUtils.NormalizeUSPhone(" +38 067 2148899 "); n.See(); Aver.AreEqual("+38 067 2148899", n); }
public void NormalizePhone2() { var n = DataEntryUtils.NormalizeUSPhone("2224415"); n.See(); Aver.AreEqual("(???) 222-4415", n); }
public void NormalizePhone12() { var n = DataEntryUtils.NormalizeUSPhone("5552224415ext.123"); Console.WriteLine(n); Assert.AreEqual("(555) 222-4415x123", n); }
public void NormalizePhone10() { var n = DataEntryUtils.NormalizeUSPhone("555-222-4415"); Console.WriteLine(n); Assert.AreEqual("(555) 222-4415", n); }
/// <summary> /// Normalizes entered string according to supplied format and culture. Normalization is done by /// adding characters so data looks more standard, i.e. adding dashes and hyphens to phone numbers etc. /// May throw exception if normalization is not possible i.e. normalize "uiug" as currency /// </summary> public static string NormalizeEnteredString(string value, DataEntryFormat format, CultureInfo culture) { //so far this is only for US culture, add logic in future to support different cultures supplied in "culture" parameter switch (format) { case DataEntryFormat.Phone: { return(DataEntryUtils.NormalizeUSPhone(value)); } default: return(value); }//switch }
public void CheckScreenName() { Aver.IsFalse(DataEntryUtils.CheckScreenName("10o")); Aver.IsFalse(DataEntryUtils.CheckScreenName("1.0o")); Aver.IsFalse(DataEntryUtils.CheckScreenName(".aa")); Aver.IsFalse(DataEntryUtils.CheckScreenName("2d-2222")); Aver.IsFalse(DataEntryUtils.CheckScreenName("DIMA-aaaaa..")); Aver.IsFalse(DataEntryUtils.CheckScreenName("дима 123")); Aver.IsFalse(DataEntryUtils.CheckScreenName(".дима 123")); Aver.IsFalse(DataEntryUtils.CheckScreenName("1дима-123")); Aver.IsFalse(DataEntryUtils.CheckScreenName("-дима")); Aver.IsFalse(DataEntryUtils.CheckScreenName("дима.")); Aver.IsTrue(DataEntryUtils.CheckScreenName("dima-qwerty")); Aver.IsTrue(DataEntryUtils.CheckScreenName("d2-2222")); Aver.IsTrue(DataEntryUtils.CheckScreenName("дима123")); Aver.IsTrue(DataEntryUtils.CheckScreenName("дима-123")); Aver.IsTrue(DataEntryUtils.CheckScreenName("дима.123")); }
public void CheckPhone() { string[] good = { "(800) 234-2345x234", "(800) 234-2345", "800 2345678", "800 234-4522", "800.2345678", "800.234.4522", "800-234-2345", "800-234-2345x234", "8882344511", "(888)2344511", "(888)234-4511", "(888)234.4511", "(888) 2344511", "(888) 234 4511", "(900) 4megood", "9004megood", "+28937498723987498237", "+8293 823098 82394", "+3423-3423-234-34", "+3423-3423-234x456", "+1 900 4ME-GOOD" }; string[] bad = { "800", "(800)", "(8888)234-4511", " (888)234-4511", "(888)234-4511 ", "(8-88)234-4511", "+1423423 +23423", ")800 23456777(", "800)1234567", "(216) 234(2345)", "345#aaaaa", "7567:242333", "+800242--3333", "+800242..3333", "+800242-.3333", "#800242.-3333", "+800242.-3333", "+(80 0)242.-3333", "(800).2423333", "(800)-2423333", "(800)2423333.", ".(800)2423333", "-(800)2423333", "((800))2423333", "(800-)2423333", "(.800)2423333", "+(800)242-3333", "(800)242. 3333", "(800)242 - 3333", "(800)242 COOL", "(800)242 - 33 - 33" }; Console.WriteLine("Good numbers:"); for (int i = 0; i < good.Length; i++) { Console.WriteLine(good[i]); Aver.IsTrue(DataEntryUtils.CheckTelephone(good[i])); } Console.WriteLine("Bad numbers:"); for (int i = 0; i < bad.Length; i++) { Console.WriteLine(bad[i]); Aver.IsFalse(DataEntryUtils.CheckTelephone(bad[i])); } }
public void CheckEmail() { string[] validEMails = { "*****@*****.**", "*****@*****.**", "*****@*****.**", "user@com", "*****@*****.**", "юзер@мояпочта.ры", "#!$%&'*+-/=?^_`{}|[email protected]", "*****@*****.**", "*****@*****.**", "user#[email protected]", "*****@*****.**", "user@example--com", "[email protected]", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" }; Console.WriteLine("==== Valid emails ===="); foreach (var email in validEMails) { Console.WriteLine(email); Aver.IsTrue(DataEntryUtils.CheckEMail(email)); } Console.WriteLine("==== Invlaid emails ===="); string[] invalidEMails = { " ", "@", "user@ ", "user@", " @example.com", "@example.com", ".@.", "dima@[email protected]", "dima [email protected]", "user", "user2example.com", "*****@*****.**", "*****@*****.**", "[email protected].", "*****@*****.**", "*****@*****.**", "*****@*****.**", "user @example.com", "[email protected] ", "user@ example.com", "us [email protected]", "user@example com", "user@example .com", "[email protected]", "*****@*****.**", "*****@*****.**", "user@examplecom-", "*****@*****.**", "*****@*****.**", "us@[email protected]", "user#example.com", "user@example/com", @"us\[email protected]", @"user@exa\mple.com", "us([email protected]", "user(comment)@example.com", "user@exa(mple.com", "us)[email protected]", "user@exa)mple.com", "us,[email protected]", "user@exa,mple.com", "us:[email protected]", "user@exa:mple.com", "us;[email protected]", "user@exa;mple.com", "us<*****@*****.**", "user@exa<mple.com", "us>[email protected]", "user@exa>mple.com", "us[[email protected]", "user@exa[mple.com", "us][email protected]", "user@exa]mple.com", "user@exam-_ple.com" }; foreach (var email in invalidEMails) { Console.WriteLine(email); Aver.IsFalse(DataEntryUtils.CheckEMail(email)); } }
public void PhoneNumberToLong_4() { Aver.AreEqual(55521910305187, DataEntryUtils.PhoneNumberToLong("555-219-1030x5187", false)); }
public void PhoneNumberToLong_3() { Aver.AreEqual(8004, DataEntryUtils.PhoneNumberToLong("800-GO4-SONY", false)); }
public void PhoneNumberToLong_2() { Aver.AreEqual(8004647669, DataEntryUtils.PhoneNumberToLong("800-GO4-SONY")); }
public void PhoneNumberToLong_1() { Aver.AreEqual(223322, DataEntryUtils.PhoneNumberToLong(" 2 2 332 2")); }
public static bool AreSimilar(Address first, Address second) { if (first == null && second == null) { return(true); } if (first == null && second != null) { return(false); } if (first != null && second == null) { return(false); } if (!string.Equals(first.PersonName, second.PersonName, StringComparison.InvariantCultureIgnoreCase)) { return(false); } if (!string.Equals(first.Company ?? string.Empty, second.Company ?? string.Empty, StringComparison.InvariantCultureIgnoreCase)) { return(false); } if (!string.Equals(DataEntryUtils.NormalizeUSPhone(first.Phone ?? string.Empty), DataEntryUtils.NormalizeUSPhone(second.Phone ?? string.Empty), StringComparison.InvariantCultureIgnoreCase)) { return(false); } if (!string.Equals(first.EMail, second.EMail)) { return(false); } if (!string.Equals(GetPostalMainPart(first.Postal), GetPostalMainPart(second.Postal), StringComparison.InvariantCultureIgnoreCase)) { return(false); } if (!string.Equals(first.City, second.City, StringComparison.InvariantCultureIgnoreCase)) { return(false); } if (!string.Equals(first.Region, second.Region, StringComparison.InvariantCultureIgnoreCase)) { return(false); } if (!string.Equals(NFX.Standards.Countries_ISO3166_1.Normalize3(first.Country ?? string.Empty), NFX.Standards.Countries_ISO3166_1.Normalize3(second.Country ?? string.Empty), StringComparison.InvariantCultureIgnoreCase)) { return(false); } if (!AddressLinesAreSimilar(first.Line1, second.Line1)) { return(false); } if (!AddressLinesAreSimilar(first.Line2, second.Line2)) { return(false); } return(true); }