Esempio n. 1
0
        public void TsStringsTwoEmpty_WritingSystemsDiffer()
        {
            ITsStrBldr   strBldr   = TsStringUtils.MakeStrBldr();
            ITsPropsBldr propsBldr = TsStringUtils.MakePropsBldr();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, 45);
            ITsTextProps propsS1 = propsBldr.GetTextProps();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, 15);
            ITsTextProps propsS2 = propsBldr.GetTextProps();

            // Create TsString #1
            strBldr.Replace(0, 0, "", propsS1);
            ITsString tssExpected = strBldr.GetString();

            // Create TsString #2
            strBldr = TsStringUtils.MakeStrBldr();
            strBldr.Replace(0, 0, "", propsS2);

            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(tssExpected, strBldr.GetString(),
                                                            out s));
            Assert.AreEqual(
                "TsStrings differ in format of run 1." + Environment.NewLine +
                "\tProps differ in ktptWs property. Expected ws <45> and var <0>, but was ws <15> and var <0>.",
                s, "Got incorrect explanation of difference");
        }
Esempio n. 2
0
        public void TsStringsDifferByRunBreaks()
        {
            ITsStrBldr   strBldr   = TsStringUtils.MakeStrBldr();
            ITsPropsBldr propsBldr = TsStringUtils.MakePropsBldr();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, 1);
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "S1");
            ITsTextProps propsS1 = propsBldr.GetTextProps();

            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "S2");
            ITsTextProps propsS2 = propsBldr.GetTextProps();

            // Create TsString #1: "Weird/Test/Dude"
            strBldr.Replace(0, 0, "Dude", propsS1);
            strBldr.Replace(0, 0, "Test", propsS2);
            strBldr.Replace(0, 0, "Weird", propsS1);
            ITsString tssExpected = strBldr.GetString();

            // Create TsString #2: "Weird/Tes/tDude"
            strBldr = TsStringUtils.MakeStrBldr();
            strBldr.Replace(0, 0, "tDude", propsS1);
            strBldr.Replace(0, 0, "Tes", propsS2);
            strBldr.Replace(0, 0, "Weird", propsS1);

            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(tssExpected, strBldr.GetString(),
                                                            out s));
            Assert.AreEqual(
                string.Format("TsStrings differ in length of run 2.{0}\tExpected length=4, but was length=3.{0}\t" +
                              "expected run:<Test>{0}\t" +
                              "     but was:<Tes>", Environment.NewLine), s,
                "Got incorrect explanation of difference");
        }
Esempio n. 3
0
        public void TsStringsTwoEmpty_ExpectedIntProp()
        {
            ITsStrBldr   strBldr   = TsStringUtils.MakeStrBldr();
            ITsPropsBldr propsBldr = TsStringUtils.MakePropsBldr();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, 45);
            ITsTextProps propsS2 = propsBldr.GetTextProps();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptSuperscript, (int)FwTextPropVar.ktpvEnum, 1);
            ITsTextProps propsS1 = propsBldr.GetTextProps();

            // Create TsString #1
            strBldr.Replace(0, 0, "", propsS1);
            ITsString tssExpected = strBldr.GetString();

            // Create TsString #2
            strBldr = TsStringUtils.MakeStrBldr();
            strBldr.Replace(0, 0, "", propsS2);

            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(tssExpected, strBldr.GetString(),
                                                            out s));
            Assert.AreEqual(
                "TsStrings differ in format of run 1." + Environment.NewLine +
                "\tProps differ in intProp type " + (int)FwTextPropType.ktptSuperscript + ". Expected <1,3>, but was <-1,-1>.",
                s, "Got incorrect explanation of difference");
        }
Esempio n. 4
0
        public void TsStringsSame()
        {
            ITsStrBldr strBldr = TsStringUtils.MakeStrBldr();

            strBldr.Replace(0, 0, "Test", TsStringUtils.MakeProps(null, 5));
            string s;

            Assert.IsTrue(TsStringHelper.TsStringsAreEqual(strBldr.GetString(),
                                                           strBldr.GetString(), out s));
        }
Esempio n. 5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Compares two ITsStrings to each other
        /// </summary>
        /// <param name="tssExpected">The ITsString expected.</param>
        /// <param name="tssActual">The actual ITsString.</param>
        /// <param name="propsWithWiggleRoom">dictionary of format properties that needn't be exact, along with their acceptable errors</param>
        /// <param name="message">The message to insert before the difference explanation.</param>
        /// ------------------------------------------------------------------------------------
        public static void AreTsStringsEqual(ITsString tssExpected, ITsString tssActual, IDictionary <int, int> propsWithWiggleRoom,
                                             string message = null)
        {
            string sWhy;

            if (!TsStringHelper.TsStringsAreEqual(tssExpected, tssActual, propsWithWiggleRoom, out sWhy))
            {
                Assert.Fail(string.IsNullOrEmpty(message) ? sWhy : message + ": " + sWhy);
            }
        }
Esempio n. 6
0
        public void NullStringDiffersFromTsString()
        {
            ITsStrBldr strBldr = TsStringUtils.MakeStrBldr();

            strBldr.Replace(0, 0, "Test", TsStringUtils.MakeProps(null, 5));
            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(strBldr.GetString(), null,
                                                            out s));
            Assert.AreEqual("TsStrings differ." + Environment.NewLine + "\tExpected <Test>, but was <null>.", s,
                            "Got incorrect explanation of difference");
        }
Esempio n. 7
0
        public void TsStringsDifferByText()
        {
            ITsStrBldr   strBldr = TsStringUtils.MakeStrBldr();
            ITsTextProps props   = TsStringUtils.MakeProps(null, 5);

            strBldr.Replace(0, 0, "Test", props);
            ITsString tssExpected = strBldr.GetString();

            strBldr.Replace(0, 4, "Crud", props);
            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(tssExpected, strBldr.GetString(),
                                                            out s));
            Assert.AreEqual(
                "TsString text differs." + Environment.NewLine + "\tExpected <Test>, but was <Crud>.", s,
                "Got incorrect explanation of difference");
        }
Esempio n. 8
0
        public void TsStringsDifferByRunCount()
        {
            ITsStrBldr strBldr = TsStringUtils.MakeStrBldr();

            strBldr.Replace(0, 0, "Bad Test", TsStringUtils.MakeProps(null, 5));
            ITsString tssExpected = strBldr.GetString();

            strBldr.Replace(0, 3, "Bad", TsStringUtils.MakeProps("Bogus", 5));
            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(tssExpected, strBldr.GetString(),
                                                            out s));
            Assert.AreEqual(
                string.Format("TsStrings have different number of runs.{0}\tExpected 1 runs, but was 2 runs.{0}\t" +
                              "Expected run 1:<Bad Test>, but was:<Bad>{0}\t" +
                              "Expected run 2:<>, but was:< Test>", Environment.NewLine), s,
                "Got incorrect explanation of difference");
        }
Esempio n. 9
0
        public void TsStringsDifferByRunFormat()
        {
            ITsStrBldr   strBldr   = TsStringUtils.MakeStrBldr();
            ITsPropsBldr propsBldr = TsStringUtils.MakePropsBldr();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, 45);
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Bogus");
            ITsTextProps propsBogus = propsBldr.GetTextProps();

            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Bogle");
            ITsTextProps propsBogle = propsBldr.GetTextProps();

            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Bugle");
            ITsTextProps propsBugle = propsBldr.GetTextProps();

            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Bungle");
            ITsTextProps propsBungle = propsBldr.GetTextProps();

            // Create TsString #1: "Weird /|Bogus{Test} /Dude"
            strBldr.Replace(0, 0, "Dude", propsBungle);
            strBldr.Replace(0, 0, "Test ", propsBogus);
            strBldr.Replace(0, 0, "Weird ", propsBugle);
            ITsString tssExpected = strBldr.GetString();

            // Create TsString #2: "Weird /|Bogle{Test} /Dude"
            strBldr = TsStringUtils.MakeStrBldr();
            strBldr.Replace(0, 0, "Dude", propsBungle);
            strBldr.Replace(0, 0, "Test ", propsBogle);
            strBldr.Replace(0, 0, "Weird ", propsBugle);

            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(tssExpected, strBldr.GetString(),
                                                            out s));
            Assert.AreEqual(
                "TsStrings differ in format of run 2." + Environment.NewLine +
                "\tProps differ in ktptNamedStyle property. Expected <Bogus>, but was <Bogle>.",
                s, "Got incorrect explanation of difference");
        }
Esempio n. 10
0
        public void NullStringsSame()
        {
            string s;

            Assert.IsTrue(TsStringHelper.TsStringsAreEqual(null, null, out s));
        }