示例#1
0
        public void AddCharacter_SuperscriptedToneNumber()
        {
            ValidCharacters   validChars  = ValidCharacters.Load(string.Empty, "Test WS", null);
            ValidCharsWrapper validCharsW = new ValidCharsWrapper(validChars);

            validChars.AddCharacter("\u00b9");
            validChars.AddCharacter("\u2079");
            Assert.AreEqual(2, validCharsW.WordFormingCharacters.Count);
            Assert.IsTrue(validCharsW.WordFormingCharacters.Contains("\u00b9"));
            Assert.IsTrue(validCharsW.WordFormingCharacters.Contains("\u2079"));
            Assert.AreEqual(0, validCharsW.NumericCharacters.Count);
            Assert.AreEqual(0, validCharsW.OtherCharacters.Count);
        }
示例#2
0
        public void AddCharacter_DuplicateOfOverriddenWordFormingChar()
        {
            string sXml = ksXmlHeader +
                          "<ValidCharacters><WordForming>a\uFFFC-</WordForming>" +
                          "<Numeric/>" +
                          "<Other>{</Other>" +
                          "</ValidCharacters>";
            ValidCharacters   validChars  = ValidCharacters.Load(sXml, "Test WS", null);
            ValidCharsWrapper validCharsW = new ValidCharsWrapper(validChars);

            Assert.AreEqual(2, validCharsW.WordFormingCharacters.Count);
            Assert.AreEqual(0, validCharsW.NumericCharacters.Count);
            Assert.AreEqual(1, validCharsW.OtherCharacters.Count);
            Assert.IsTrue(validChars.IsWordForming("-"));
            Assert.IsFalse(validChars.IsWordForming("{"));
            validChars.AddCharacter("-");
            Assert.AreEqual(2, validCharsW.WordFormingCharacters.Count);
            Assert.IsTrue(validCharsW.WordFormingCharacters.Contains("a"));
            Assert.IsTrue(validCharsW.WordFormingCharacters.Contains("-"));
            Assert.IsTrue(validChars.IsWordForming("-"));
            Assert.AreEqual(0, validCharsW.NumericCharacters.Count);
            Assert.AreEqual(1, validCharsW.OtherCharacters.Count);
            Assert.IsTrue(validCharsW.OtherCharacters.Contains("{"));
            Assert.IsFalse(validChars.IsWordForming("{"));
        }
示例#3
0
        public void AddCharacter_Duplicate()
        {
            ValidCharacters   validChars  = ValidCharacters.Load(string.Empty, "Test WS", null);
            ValidCharsWrapper validCharsW = new ValidCharsWrapper(validChars);

            validChars.AddCharacter("a");
            validChars.AddCharacter("a");
            Assert.AreEqual(1, validCharsW.WordFormingCharacters.Count);
            Assert.IsTrue(validCharsW.WordFormingCharacters.Contains("a"));
            Assert.AreEqual(0, validCharsW.NumericCharacters.Count);
            Assert.AreEqual(0, validCharsW.OtherCharacters.Count);
            Assert.AreEqual(ksXmlHeader +
                            "<ValidCharacters><WordForming>a</WordForming>" +
                            "<Numeric /><Other /></ValidCharacters>",
                            validChars.XmlString.Replace(Environment.NewLine, string.Empty).Replace(">  <", "><"));
        }
示例#4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Verifies the sort order of characters added to the specified valid characters
        /// object.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void VerifySortOrder(ValidCharacters validChars)
        {
            ValidCharsWrapper validCharsW = new ValidCharsWrapper(validChars);

            Assert.AreEqual("b", validCharsW.WordFormingCharacters[0]);
            Assert.AreEqual("c", validCharsW.WordFormingCharacters[1]);
            Assert.AreEqual("t", validCharsW.WordFormingCharacters[2]);
            Assert.AreEqual("z", validCharsW.WordFormingCharacters[3]);

            validChars.AddCharacter("8");
            validChars.AddCharacter("7");
            validChars.AddCharacter("6");
            validChars.AddCharacter("5");

            Assert.AreEqual("5", validCharsW.NumericCharacters[0]);
            Assert.AreEqual("6", validCharsW.NumericCharacters[1]);
            Assert.AreEqual("7", validCharsW.NumericCharacters[2]);
            Assert.AreEqual("8", validCharsW.NumericCharacters[3]);
        }
示例#5
0
        private void EnsureQuoteAndHyphenWordForming(CoreWritingSystemDefinition wsObj)
        {
            ValidCharacters validChars        = ValidCharacters.Load(wsObj);
            var             fChangedSomething = false;

            if (!validChars.IsWordForming('-'))
            {
                validChars.AddCharacter("-", ValidCharacterType.WordForming);
                fChangedSomething = true;
            }
            if (!validChars.IsWordForming('\''))
            {
                validChars.AddCharacter("'", ValidCharacterType.WordForming);
                fChangedSomething = true;
            }
            if (!fChangedSomething)
            {
                return;
            }
            validChars.SaveTo(wsObj);
        }
示例#6
0
        public void SortAfterAddSingles()
        {
            ValidCharacters validChars = ValidCharacters.Load(string.Empty, "Test WS", null);

            try
            {
                validChars.InitSortComparer("en");
                validChars.AddCharacter("z");
                validChars.AddCharacter("c");
                validChars.AddCharacter("t");
                validChars.AddCharacter("b");
                validChars.AddCharacter("8");
                validChars.AddCharacter("7");
                validChars.AddCharacter("6");
                validChars.AddCharacter("5");
                VerifySortOrder(validChars);
            }
            finally
            {
                validChars.Dispose();
            }
        }
示例#7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Verifies the sort order of characters added to the specified valid characters
		/// object.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void VerifySortOrder(ValidCharacters validChars)
		{
			ValidCharsWrapper validCharsW = new ValidCharsWrapper(validChars);
			Assert.AreEqual("b", validCharsW.WordFormingCharacters[0]);
			Assert.AreEqual("c", validCharsW.WordFormingCharacters[1]);
			Assert.AreEqual("t", validCharsW.WordFormingCharacters[2]);
			Assert.AreEqual("z", validCharsW.WordFormingCharacters[3]);

			validChars.AddCharacter("8");
			validChars.AddCharacter("7");
			validChars.AddCharacter("6");
			validChars.AddCharacter("5");

			Assert.AreEqual("5", validCharsW.NumericCharacters[0]);
			Assert.AreEqual("6", validCharsW.NumericCharacters[1]);
			Assert.AreEqual("7", validCharsW.NumericCharacters[2]);
			Assert.AreEqual("8", validCharsW.NumericCharacters[3]);
		}