public void testToGwoyeuRomatzyhStringArray() { // any input of non-Chinese characters will return null { Assert.IsNull(PinyinHelper.ToGwoyeuRomatzyhStringArray('A')); Assert.IsNull(PinyinHelper.ToGwoyeuRomatzyhStringArray('z')); Assert.IsNull(PinyinHelper.ToGwoyeuRomatzyhStringArray(',')); Assert.IsNull(PinyinHelper.ToGwoyeuRomatzyhStringArray('。')); } // Chinese characters // single pronounciation { string[] expectedPinyinArray = new string[] { "lii" }; string[] pinyinArray = PinyinHelper.ToGwoyeuRomatzyhStringArray('李'); Assert.AreEqual(expectedPinyinArray.Length, pinyinArray.Length); for (int i = 0; i < expectedPinyinArray.Length; i++) { Assert.AreEqual(expectedPinyinArray[i], pinyinArray[i]); } } { string[] expectedPinyinArray = new string[] { "chyou" }; string[] pinyinArray = PinyinHelper.ToGwoyeuRomatzyhStringArray('球'); Assert.AreEqual(expectedPinyinArray.Length, pinyinArray.Length); for (int i = 0; i < expectedPinyinArray.Length; i++) { Assert.AreEqual(expectedPinyinArray[i], pinyinArray[i]); } } { string[] expectedPinyinArray = new string[] { "juang" }; string[] pinyinArray = PinyinHelper.ToGwoyeuRomatzyhStringArray('桩'); Assert.AreEqual(expectedPinyinArray.Length, pinyinArray.Length); for (int i = 0; i < expectedPinyinArray.Length; i++) { Assert.AreEqual(expectedPinyinArray[i], pinyinArray[i]); } } { string[] expectedPinyinArray = new string[] { "fuh" }; string[] pinyinArray = PinyinHelper.ToGwoyeuRomatzyhStringArray('付'); Assert.AreEqual(expectedPinyinArray.Length, pinyinArray.Length); for (int i = 0; i < expectedPinyinArray.Length; i++) { Assert.AreEqual(expectedPinyinArray[i], pinyinArray[i]); } } // multiple pronounciations { string[] expectedPinyinArray = new string[] { "chwan", "juann" }; string[] pinyinArray = PinyinHelper.ToGwoyeuRomatzyhStringArray('传'); Assert.AreEqual(expectedPinyinArray.Length, pinyinArray.Length); for (int i = 0; i < expectedPinyinArray.Length; i++) { Assert.AreEqual(expectedPinyinArray[i], pinyinArray[i]); } } { string[] expectedPinyinArray = new string[] { ".me", ".mha", "iau" }; string[] pinyinArray = PinyinHelper.ToGwoyeuRomatzyhStringArray('么'); Assert.AreEqual(expectedPinyinArray.Length, pinyinArray.Length); for (int i = 0; i < expectedPinyinArray.Length; i++) { Assert.AreEqual(expectedPinyinArray[i], pinyinArray[i]); } } { string[] expectedPinyinArray = new string[] { "liuh", "luh" }; string[] pinyinArray = PinyinHelper.ToGwoyeuRomatzyhStringArray('绿'); Assert.AreEqual(expectedPinyinArray.Length, pinyinArray.Length); for (int i = 0; i < expectedPinyinArray.Length; i++) { Assert.AreEqual(expectedPinyinArray[i], pinyinArray[i]); } } }