tests/DotNetCommon.Test/PinYinTests/WordHelpTests.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using NUnit.Framework;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Text;
using helper = DotNetCommon.PinYin.WordsHelper;

namespace DotNetCommon.Test.PinYinTests
{
    [TestFixture]
    public class WordHelpTests
    {
        [Test]
        public void GetPinyinTest()
        {
            var str = helper.GetPinyin("王小明");
            str.ShouldBe("WangXiaoMing");

            //多音字
            str = helper.GetPinyin("银行");
            str.ShouldBe("YinHang");
            str = helper.GetPinyin("行走");
            str.ShouldBe("XingZou");

            //多音字Bug
            str = helper.GetPinyin("我的笔记本");
            //str="WoDiBiJiBen";  "WoDeBiJiBen"
            str = helper.GetPinyin("什么");
            //"ShiYao" "ShenMe"

            //带拼音
            str = helper.GetPinyin("王小明", true);
            str.ShouldBe("WángXiǎoMíng");

            //带分隔符
            str = helper.GetPinyin("王小明", ",");
            str.ShouldBe("Wang,Xiao,Ming");

            //带英文
            str = helper.GetPinyin("王小明how old are you?");
            str.ShouldBe("WangXiaoMinghow old are you?");
        }

        [Test]
        public void GetAllPinyinTest()
        {
            var str = helper.GetAllPinyin('我');
            str.Count.ShouldBe(1);
            str[0].ShouldBe("Wo");
            str = helper.GetAllPinyin('的');
            str.Count.ShouldBe(2);
            str[0].ShouldBe("De");
            str[1].ShouldBe("Di");
            str = helper.GetAllPinyin('行', true);
            str.Count.ShouldBe(5);
        }

        [Test]
        public void GetFirstPinyinTest()
        {
后面还有 56 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。