Esempio n. 1
0
        public void AsLettersOnly_AreEqual()
        {
            KeyValuePair <string, string>[] dataset =
            {
                new KeyValuePair <string, string>("abcdefghij", "abcdefghij"),                   // Lower letters
                new KeyValuePair <string, string>("WpuKmIcOTc", "WpuKmIcOTc"),                   // Upper and lower letters
                new KeyValuePair <string, string>("Xs3Xu9pgkz", "XsXupgkz"),                     // With numbers
                new KeyValuePair <string, string>("JM;xk.laeP", "JMxklaeP"),                     // With special chars
                new KeyValuePair <string, string>("&}}KqTl@;C5", "KqTlC"),                       // With numbers and special characters
                new KeyValuePair <string, string>("@u?1e\nLEbj", "ueLEbj"),                      // With numbers, special chars and escapes
                new KeyValuePair <string, string>("CXI-4208", "CXI"),                            // Vehicle plate
                new KeyValuePair <string, string>("12345", string.Empty),                        // Only numbers
                new KeyValuePair <string, string>("cD", "cD"),                                   // Lower and upper letters
                new KeyValuePair <string, string>("", string.Empty),                             // Empty text
                new KeyValuePair <string, string>("a", "a"),                                     // Lower letter
                new KeyValuePair <string, string>("B", "B"),                                     // Upper letter
                new KeyValuePair <string, string>("0", string.Empty),                            // Only numbers
                new KeyValuePair <string, string>("!", string.Empty),                            // Special characters
                new KeyValuePair <string, string>(string.Empty, string.Empty),                   // Empty text
                new KeyValuePair <string, string>(Environment.NewLine, string.Empty),            // Special characters
            };

            foreach (var data in dataset)
            {
                var newLine = Environment.NewLine;
                var result  = Format.AsLettersOnly(data.Key);

                var message = string.Format(
                    newLine + "-----------------------------------" +
                    newLine + "| Expected for [" + data.Key + "] --> [" + data.Value + "]." +
                    newLine + "| Obtained for [" + data.Key + "] --> [" + result + "]." +
                    newLine + "-----------------------------------"
                    );

                Assert.AreEqual(result, data.Value, message);
            }
        }