public void TestMethod_File02_BackSplashSpliter() { #region file data String fileContent = @"xiāng\xiàng bù\fǒu jiào\jiāo zé\zhái yàn\yān yǒu\yòu fù\fǔ hé\hē\hè"; String fileToTestFileName = string.Format("PinYin2ZhuYin.TestFile_{0}.txt", DateTime.Now.ToFileTime()); File.WriteAllText(fileToTestFileName, fileContent, Encoding.UTF8); PinYin2ZhuYin.ConvertFile(fileToTestFileName); string actualResultFileName = PinYin2ZhuYin.ConvertFile(fileToTestFileName, true); String fileActualContent = File.ReadAllText(actualResultFileName, Encoding.UTF8); Console.WriteLine("FileToTestFileName:{0}, ActualFileName:{1}", fileToTestFileName, actualResultFileName); string fileExpectedContent = @"ㄒㄧㄤˉ\ㄒㄧㄤˋ ㄅㄨˋ\ㄈㄡˇ ㄐㄧㄠˋ\ㄐㄧㄠˉ ㄗㄜˊ\ㄓㄞˊ ㄧㄢˋ\ㄧㄢˉ ㄧㄡˇ\ㄧㄡˋ ㄈㄨˋ\ㄈㄨˇ ㄏㄜˊ\ㄏㄜˉ\ㄏㄜˋ "; Assert.AreEqual <string>(fileExpectedContent, fileActualContent); #endregion }
public void TestMethod_File03_BlankSpace_Splitter() { #region file data String fileContent = @"xiāng xiàng bù fǒu jiào jiāo zé zhái yàn yān yǒu yòu fù fǔ hé hē hè"; String fileToTestFileName = string.Format("PinYin2ZhuYin.TestFile_{0}.txt", DateTime.Now.ToFileTime()); File.WriteAllText(fileToTestFileName, fileContent, Encoding.UTF8); PinYin2ZhuYin.ConvertFile(fileToTestFileName); string actualResultFileName = PinYin2ZhuYin.ConvertFile(fileToTestFileName, true); String fileActualContent = File.ReadAllText(actualResultFileName, Encoding.UTF8); Console.WriteLine("FileToTestFileName:{0}, ActualFileName:{1}", fileToTestFileName, actualResultFileName); string fileExpectedContent = @"ㄒㄧㄤˉ ㄒㄧㄤˋ ㄅㄨˋ ㄈㄡˇ ㄐㄧㄠˋ ㄐㄧㄠˉ ㄗㄜˊ ㄓㄞˊ ㄧㄢˋ ㄧㄢˉ ㄧㄡˇ ㄧㄡˋ ㄈㄨˋ ㄈㄨˇ ㄏㄜˊ ㄏㄜˉ ㄏㄜˋ "; Assert.AreEqual <string>(fileExpectedContent, fileActualContent); #endregion }
public void TestMethod02() { Assert.AreEqual <string>("ㄖㄣˊ ㄓ ㄔㄨ", PinYin2ZhuYin.Convert("rén zhī chū")); Assert.AreEqual <string>("ㄖㄣˊ ㄓˉ ㄔㄨˉ", PinYin2ZhuYin.Convert("rén zhī chū", true)); Assert.AreEqual <string>("ㄒㄧㄤˉ\\ㄒㄧㄤˋ", PinYin2ZhuYin.Convert("xiāng\\xiàng", true)); Assert.AreEqual <string>("ㄒㄧㄤ\\ㄒㄧㄤˋ", PinYin2ZhuYin.Convert("xiāng\\xiàng")); }