예제 #1
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();
        }
예제 #2
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();
        }