示例#1
0
        public void get_IsWordForming()
        {
            var wsManager = new WritingSystemManager();
            CoreWritingSystemDefinition ws = wsManager.Set("zh-CN");

            ws.CharacterSets.Add(new CharacterSetDefinition("main")
            {
                Characters = { "e", "f", "g", "h", "'" }
            });
            ws.CharacterSets.Add(new CharacterSetDefinition("numeric")
            {
                Characters = { "4", "5" }
            });
            ws.CharacterSets.Add(new CharacterSetDefinition("punctuation")
            {
                Characters = { ",", "!", "*" }
            });
            Assert.IsTrue(ws.get_IsWordForming('\''));
            Assert.IsFalse(ws.get_IsWordForming('"'));

            ws.CharacterSets.Clear();
            Assert.IsFalse(ws.get_IsWordForming('\''));
            Assert.IsFalse(ws.get_IsWordForming('"'));
            wsManager.Save();
        }
示例#2
0
        public void GetStrFromWs()
        {
            var wsManager = new WritingSystemManager();

            Assert.IsNull(wsManager.GetStrFromWs(1));
            CoreWritingSystemDefinition ws = wsManager.Set("en-US");

            Assert.AreEqual("en-US", wsManager.GetStrFromWs(ws.Handle));
            wsManager.Save();
        }
示例#3
0
        public void GetWsFromStr()
        {
            var wsManager = new WritingSystemManager();

            Assert.AreEqual(0, wsManager.GetWsFromStr("en-US"));
            CoreWritingSystemDefinition ws = wsManager.Set("en-US");

            Assert.AreEqual(ws.Handle, wsManager.GetWsFromStr("en-US"));
            wsManager.Save();
        }
示例#4
0
        public void get_EngineOrNull()
        {
            var wsManager = new WritingSystemManager();

            Assert.IsNull(wsManager.get_EngineOrNull(1));
            CoreWritingSystemDefinition ws = wsManager.Set("en-US");

            Assert.AreSame(ws, wsManager.get_EngineOrNull(ws.Handle));
            wsManager.Save();
        }
示例#5
0
        public void get_Engine()
        {
            var wsManager = new WritingSystemManager();
            CoreWritingSystemDefinition enWs   = wsManager.Set("en-US");
            ILgWritingSystem            enLgWs = wsManager.get_Engine("en-US");

            Assert.AreSame(enWs, enLgWs);

            Assert.IsFalse(wsManager.Exists("en-Latn-US"));
            // this should create a new writing system, since it doesn't exist
            ILgWritingSystem enUsLgWs = wsManager.get_Engine("en-US-fonipa");

            Assert.IsTrue(wsManager.Exists("en-US-fonipa"));
            Assert.IsTrue(wsManager.Exists(enUsLgWs.Handle));
            CoreWritingSystemDefinition enUsWs = wsManager.Get("en-US-fonipa");

            Assert.AreSame(enUsWs, enUsLgWs);
            wsManager.Save();
        }
示例#6
0
        public void SerializeDeserialize()
        {
            string storePath = PrepareTempStore("Store");

            var projectSettingsStore = new TestSettingsStore();
            var userSettingsStore    = new TestSettingsStore();
            // serialize
            var wsManager = new WritingSystemManager(new TestCoreLdmlInFolderWritingSystemRepository(storePath, projectSettingsStore, userSettingsStore));
            CoreWritingSystemDefinition ws = wsManager.Set("en-US");

            ws.SpellCheckingId = "en_US";
            ws.MatchedPairs.Add(new MatchedPair("(", ")", true));
            ws.WindowsLcid = 0x409.ToString(CultureInfo.InvariantCulture);
            ws.CharacterSets.Add(new CharacterSetDefinition("main")
            {
                Characters = { "a", "b", "c" }
            });
            ws.LegacyMapping = "legacy mapping";
            wsManager.Save();

            // deserialize
            wsManager = new WritingSystemManager(new TestCoreLdmlInFolderWritingSystemRepository(storePath, projectSettingsStore, userSettingsStore));
            Assert.IsTrue(wsManager.Exists("en-US"));
            ws = wsManager.Get("en-US");
            Assert.AreEqual("Eng", ws.Abbreviation);
            Assert.AreEqual("English", ws.Language.Name);
            Assert.AreEqual("en_US", ws.SpellCheckingId);
            Assert.AreEqual("United States", ws.Region.Name);
            Assert.That(ws.MatchedPairs, Is.EqualTo(new[] { new MatchedPair("(", ")", true) }));
            Assert.AreEqual(0x409.ToString(CultureInfo.InvariantCulture), ws.WindowsLcid);
            Assert.That(ws.CharacterSets.Count, Is.EqualTo(1));
            Assert.That(ws.CharacterSets[0].ValueEquals(new CharacterSetDefinition("main")
            {
                Characters = { "a", "b", "c" }
            }), Is.True);
            Assert.AreEqual("legacy mapping", ws.LegacyMapping);
            wsManager.Save();
        }