示例#1
0
        public void RandomTest()
        {
            const int Tests = 100;

            for (int i = 0; i < Tests; ++i)
            {
                string test = String.Join(" ",
                                          String.Concat(new String('.', rnd.Next(40, 201)).Select(_ => chars[rnd.Next(0, chars.Length)]))
                                          .Split(' ').Where(s => !String.IsNullOrEmpty(s))).Trim();
                string[] words      = test.Split(' ');
                string   minorWords = String.Join(" ",
                                                  new string[]
                {
                    words[rnd.Next(0, words.Length)], words[rnd.Next(0, words.Length)],
                    words[rnd.Next(0, words.Length)], words[rnd.Next(0, words.Length)]
                }.Distinct());

                string expected = TitleCaseTrue(test, minorWords);
                string actual   = TitleCase.titleCase(test, minorWords);

                Assert.AreEqual(expected, actual);
            }
        }
示例#2
0
 public void MyTest2()
 {
     Assert.AreEqual("", TitleCase.titleCase(""));
 }
示例#3
0
 public void MyTest3()
 {
     Assert.AreEqual("The Quick Brown Fox", TitleCase.titleCase("the quick brown fox"));
 }
示例#4
0
 public void MyTest(string sampleTitle, string sampleMinorWords, string expected)
 {
     Assert.AreEqual(expected, TitleCase.titleCase(sampleTitle, sampleMinorWords));
 }