public void TsStringsDifferByRunBreaks()
        {
            ITsStrBldr   strBldr   = TsStrBldrClass.Create();
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            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 = TsStrBldrClass.Create();
            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");
        }
        public void TsStringsTwoEmpty_ExpectedIntProp()
        {
            ITsStrBldr   strBldr   = TsStrBldrClass.Create();
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            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 = TsStrBldrClass.Create();
            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");
        }
示例#3
0
        public void NullStringsSame()
        {
            CheckDisposed();
            string s;

            Assert.IsTrue(TsStringHelper.TsStringsAreEqual(null, null, out s));
        }
示例#4
0
        public void TsStringsTwoEmpty_ExpectedIntProp()
        {
            CheckDisposed();
            ITsStrBldr   strBldr   = TsStrBldrClass.Create();
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

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

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

            // Create TsString #2
            strBldr = TsStrBldrClass.Create();
            strBldr.Replace(0, 0, "", null);

            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(tssExpected, strBldr.GetString(),
                                                            out s));
            Assert.AreEqual(
                "TsStrings differ in format of run 1.\n\t" +
                "Props differ in ktptWs property. Expected <45>, but was <-1>.",
                s, "Got incorrect explanation of difference");
        }
        public void TsStringsTwoEmpty_WritingSystemsDiffer()
        {
            ITsStrBldr   strBldr   = TsStrBldrClass.Create();
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            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 = TsStrBldrClass.Create();
            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");
        }
示例#6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Compares two ITsStrings to each other
        /// </summary>
        /// <param name="tssExpected">The ITsString expected.</param>
        /// <param name="tss">The actual ITsString.</param>
        /// <param name="message">The message to insert before the difference explanation.</param>
        /// ------------------------------------------------------------------------------------
        public static void AreTsStringsEqual(ITsString tssExpected, ITsString tss, string message)
        {
            string sWhy;

            if (!TsStringHelper.TsStringsAreEqual(tssExpected, tss, out sWhy))
            {
                Assert.Fail(string.IsNullOrEmpty(message) ? sWhy : message + ": " + sWhy);
            }
        }
示例#7
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);
            }
        }
        public void TsStringsSame()
        {
            ITsStrBldr strBldr = TsStrBldrClass.Create();

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

            Assert.IsTrue(TsStringHelper.TsStringsAreEqual(strBldr.GetString(),
                                                           strBldr.GetString(), out s));
        }
示例#9
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Evaluate actual parameter to see if it's what was expected
        /// </summary>
        /// <param name="val">Actaul parameter</param>
        /// <returns><c>true</c> if actual param equals expected</returns>
        /// ------------------------------------------------------------------------------------
        public override bool Eval(object val)
        {
            if (!(val is ITsString))
            {
                m_sHowDifferent = "Actual parameter was not a TsString";
                return(false);
            }

            return(TsStringHelper.TsStringsAreEqual(m_tssExpected, (ITsString)val,
                                                    out m_sHowDifferent));
        }
示例#10
0
        public void TsStringsTwoEmpty_NoProps()
        {
            CheckDisposed();
            ITsStrBldr strBldr = TsStrBldrClass.Create();

            strBldr.Replace(0, 0, "", null);
            string s;

            Assert.IsTrue(TsStringHelper.TsStringsAreEqual(strBldr.GetString(),
                                                           strBldr.GetString(), out s));
        }
示例#11
0
        public void NullStringDiffersFromTsString()
        {
            ITsStrBldr      strBldr   = TsStrBldrClass.Create();
            ITsPropsFactory propsFact = TsPropsFactoryClass.Create();

            strBldr.Replace(0, 0, "Test", propsFact.MakeProps(null, 5, 0));
            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");
        }
示例#12
0
        public void NullStringDiffersFromTsString()
        {
            CheckDisposed();
            ITsStrBldr strBldr = TsStrBldrClass.Create();

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

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(strBldr.GetString(), null,
                                                            out s));
            Assert.AreEqual("TsStrings differ.\n\tExpected <Test>, but was <null>.", s,
                            "Got incorrect explanation of difference");
        }
示例#13
0
        public void TsStringsDifferByText()
        {
            CheckDisposed();
            ITsStrBldr strBldr = TsStrBldrClass.Create();

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

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

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(tssExpected, strBldr.GetString(),
                                                            out s));
            Assert.AreEqual(
                "TsString text differs.\n\tExpected <Test>, but was <Crud>.", s,
                "Got incorrect explanation of difference");
        }
示例#14
0
        public void TsStringsDifferByText()
        {
            ITsStrBldr      strBldr   = TsStrBldrClass.Create();
            ITsPropsFactory propsFact = TsPropsFactoryClass.Create();
            ITsTextProps    props     = propsFact.MakeProps(null, 5, 0);

            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");
        }
示例#15
0
        public void TsStringsDifferByRunCount()
        {
            ITsStrBldr      strBldr   = TsStrBldrClass.Create();
            ITsPropsFactory propsFact = TsPropsFactoryClass.Create();

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

            strBldr.Replace(0, 3, "Bad", propsFact.MakeProps("Bogus", 5, 0));
            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");
        }
示例#16
0
        public void TsStringsDifferByRunCount()
        {
            CheckDisposed();
            ITsStrBldr strBldr = TsStrBldrClass.Create();

            strBldr.Replace(0, 0, "Bad Test", null);
            ITsString    tssExpected = strBldr.GetString();
            ITsPropsBldr propsBldr   = TsPropsBldrClass.Create();

            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Bogus");
            strBldr.Replace(0, 3, "Bad", propsBldr.GetTextProps());
            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(tssExpected, strBldr.GetString(),
                                                            out s));
            Assert.AreEqual(
                "TsStrings have different number of runs.\n\tExpected 1 runs, but was 2 runs.\n\t" +
                "Expected run 1:<Bad Test>, but was:<Bad>\n\t" +
                "Expected run 2:<>, but was:< Test>", s,
                "Got incorrect explanation of difference");
        }
示例#17
0
        public void TsStringsDifferByRunFormat()
        {
            ITsStrBldr   strBldr   = TsStrBldrClass.Create();
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            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 = TsStrBldrClass.Create();
            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");
        }
示例#18
0
        public void NullStringsSame()
        {
            string s;

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