Example #1
0
        public void SetProperties_TwoRunBldrReplacesFirstWithoutOverlappingSecondSamePropertiesAsFirst_UpdatesProperties()
        {
            TsStrBldr tsb = CreateMixedWSBldr();

            tsb.SetProperties(0, EnglishFont1Text.Length + 1, new TsTextProps(EnglishWS));
            Assert.That(tsb.RunCount, Is.EqualTo(2));
            Assert.That(tsb.get_RunText(0), Is.EqualTo("This is a test! "));
            Assert.That(GetWS(tsb, 0), Is.EqualTo(EnglishWS));
            Assert.That(tsb.get_RunText(1), Is.EqualTo("¡Esto es una prueba!"));
            Assert.That(GetWS(tsb, 1), Is.EqualTo(SpanishWS));
            int ichMin, ichLim;

            tsb.GetBoundsOfRun(0, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(0));
            Assert.That(ichLim, Is.EqualTo(EnglishFont1Text.Length + 1));
            tsb.GetBoundsOfRun(1, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(EnglishFont1Text.Length + 1));
            Assert.That(ichLim, Is.EqualTo(tsb.Length));
        }
Example #2
0
        public void SetStrPropValue_TwoRunBldrRangeOverlapsBothRemoveProperty_UpdatesProperties()
        {
            TsStrBldr tsb = CreateMixedFontBldr();

            tsb.SetStrPropValue(6, 27, (int)FwTextPropType.ktptFontFamily, null);
            Assert.That(tsb.RunCount, Is.EqualTo(3));
            Assert.That(tsb.get_RunText(1), Is.EqualTo("s a test! How are you"));
            Assert.That(GetFont(tsb, 1), Is.Null);
            int ichMin, ichLim;

            tsb.GetBoundsOfRun(0, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(0));
            Assert.That(ichLim, Is.EqualTo(6));
            tsb.GetBoundsOfRun(1, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(6));
            Assert.That(ichLim, Is.EqualTo(27));
            tsb.GetBoundsOfRun(2, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(27));
            Assert.That(ichLim, Is.EqualTo(tsb.Length));
        }
Example #3
0
        public void SetIntPropValues_TwoRunBldrRangeOverlapsBothRemoveProperty_UpdatesProperties()
        {
            TsStrBldr tsb = CreateMixedWSBldr();

            tsb.SetIntPropValues(6, 27, (int)FwTextPropType.ktptWs, -1, -1);
            Assert.That(tsb.RunCount, Is.EqualTo(3));
            Assert.That(tsb.get_RunText(1), Is.EqualTo("s a test! ¡Esto es un"));
            Assert.That(GetWS(tsb, 1), Is.EqualTo(-1));
            int ichMin, ichLim;

            tsb.GetBoundsOfRun(0, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(0));
            Assert.That(ichLim, Is.EqualTo(6));
            tsb.GetBoundsOfRun(1, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(6));
            Assert.That(ichLim, Is.EqualTo(27));
            tsb.GetBoundsOfRun(2, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(27));
            Assert.That(ichLim, Is.EqualTo(tsb.Length));
        }
Example #4
0
        public void SetProperties_TwoRunBldrRangeOverlapsBoth_UpdatesProperties()
        {
            TsStrBldr tsb = CreateMixedWSBldr();

            tsb.SetProperties(6, 27, new TsTextProps(FrenchWS));
            Assert.That(tsb.RunCount, Is.EqualTo(3));
            Assert.That(tsb.get_RunText(1), Is.EqualTo("s a test! ¡Esto es un"));
            Assert.That(GetWS(tsb, 1), Is.EqualTo(FrenchWS));
            int ichMin, ichLim;

            tsb.GetBoundsOfRun(0, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(0));
            Assert.That(ichLim, Is.EqualTo(6));
            tsb.GetBoundsOfRun(1, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(6));
            Assert.That(ichLim, Is.EqualTo(27));
            tsb.GetBoundsOfRun(2, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(27));
            Assert.That(ichLim, Is.EqualTo(tsb.Length));
        }
Example #5
0
        public void Replace_TwoRunBldrNonEmptyTextOverlapsBoth_ReplacesText()
        {
            TsStrBldr tsb = CreateMixedWSBldr();

            tsb.Replace(5, 28, "was", new TsTextProps(FrenchWS));
            Assert.That(tsb.Text, Is.EqualTo("This was prueba!"));
            Assert.That(tsb.RunCount, Is.EqualTo(3));
            Assert.That(GetWS(tsb, 0), Is.EqualTo(EnglishWS));
            Assert.That(GetWS(tsb, 1), Is.EqualTo(FrenchWS));
            Assert.That(GetWS(tsb, 2), Is.EqualTo(SpanishWS));
            int ichMin, ichLim;

            tsb.GetBoundsOfRun(0, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(0));
            Assert.That(ichLim, Is.EqualTo(5));
            tsb.GetBoundsOfRun(1, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(5));
            Assert.That(ichLim, Is.EqualTo(8));
            tsb.GetBoundsOfRun(2, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(8));
            Assert.That(ichLim, Is.EqualTo(tsb.Length));
        }
Example #6
0
        public void Replace_OneRunBldrNonEmptyTextPartialRange_ReplacesText()
        {
            TsStrBldr tsb = CreateOneRunBldr();

            tsb.Replace(5, 7, "was", new TsTextProps(FrenchWS));
            Assert.That(tsb.Text, Is.EqualTo("This was a test!"));
            Assert.That(tsb.RunCount, Is.EqualTo(3));
            Assert.That(GetWS(tsb, 0), Is.EqualTo(EnglishWS));
            Assert.That(GetWS(tsb, 1), Is.EqualTo(FrenchWS));
            Assert.That(GetWS(tsb, 2), Is.EqualTo(EnglishWS));
            int ichMin, ichLim;

            tsb.GetBoundsOfRun(0, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(0));
            Assert.That(ichLim, Is.EqualTo(5));
            tsb.GetBoundsOfRun(1, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(5));
            Assert.That(ichLim, Is.EqualTo(8));
            tsb.GetBoundsOfRun(2, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(8));
            Assert.That(ichLim, Is.EqualTo(tsb.Length));
        }
Example #7
0
        public void Replace_OneRunBldrEmptyTextPartialRange_RemovesText()
        {
            TsStrBldr tsb = CreateOneRunBldr();

            tsb.Replace(5, 8, string.Empty, new TsTextProps(FrenchWS));
            Assert.That(tsb.Text, Is.EqualTo("This a test!"));
            Assert.That(tsb.RunCount, Is.EqualTo(1));
            Assert.That(GetWS(tsb, 0), Is.EqualTo(EnglishWS));
            int ichMin, ichLim;

            tsb.GetBoundsOfRun(0, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(0));
            Assert.That(ichLim, Is.EqualTo(tsb.Length));
        }
Example #8
0
        public void SetProperties_TwoRunBldrAlmostReplacesFirstButLeavesJustOneCharacterSamePropertiesAsSecond_UpdatesProperties()
        {
            TsStrBldr tsb = CreateMixedWSBldr();

            tsb.SetProperties(0, EnglishFont1Text.Length, new TsTextProps(SpanishWS));
            Assert.That(tsb.RunCount, Is.EqualTo(3));
            Assert.That(tsb.get_RunText(0), Is.EqualTo("This is a test!"));
            Assert.That(GetWS(tsb, 0), Is.EqualTo(SpanishWS));
            Assert.That(tsb.get_RunText(1), Is.EqualTo(" "));
            Assert.That(GetWS(tsb, 1), Is.EqualTo(EnglishWS));
            Assert.That(GetWS(tsb, 2), Is.EqualTo(SpanishWS));
            int ichMin, ichLim;

            tsb.GetBoundsOfRun(0, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(0));
            Assert.That(ichLim, Is.EqualTo(EnglishFont1Text.Length));
            tsb.GetBoundsOfRun(1, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(EnglishFont1Text.Length));
            Assert.That(ichLim, Is.EqualTo(EnglishFont1Text.Length + 1));
            tsb.GetBoundsOfRun(2, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(EnglishFont1Text.Length + 1));
            Assert.That(ichLim, Is.EqualTo(tsb.Length));
        }
Example #9
0
        public void SetProperties_TwoRunBldrReplacesFirstAndOverlapsSecondByOneCharacterSamePropertiesAsSecond_UpdatesProperties()
        {
            TsStrBldr tsb = CreateMixedWSBldr();

            tsb.SetProperties(0, EnglishFont1Text.Length + 2, new TsTextProps(SpanishWS));
            Assert.That(tsb.RunCount, Is.EqualTo(1));
            Assert.That(tsb.get_RunText(0), Is.EqualTo("This is a test! ¡Esto es una prueba!"));
            Assert.That(GetWS(tsb, 0), Is.EqualTo(SpanishWS));
            int ichMin, ichLim;

            tsb.GetBoundsOfRun(0, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(0));
            Assert.That(ichLim, Is.EqualTo(tsb.Length));
        }
Example #10
0
        public void Replace_OneRunBldrNonEmptyTextEmptyRangeNullProps_InsertsText()
        {
            TsStrBldr tsb = CreateOneRunBldr();

            tsb.Replace(tsb.Length, tsb.Length, " text", null);
            Assert.That(tsb.Text, Is.EqualTo(EnglishFont1Text + " text"));
            Assert.That(tsb.RunCount, Is.EqualTo(1));
            Assert.That(GetWS(tsb, 0), Is.EqualTo(EnglishWS));
            int ichMin, ichLim;

            tsb.GetBoundsOfRun(0, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(0));
            Assert.That(ichLim, Is.EqualTo(tsb.Length));
        }
Example #11
0
        public void Replace_OneRunBldrNonEmptyTextFullRange_ReplacesText()
        {
            TsStrBldr tsb = CreateOneRunBldr();

            tsb.Replace(0, tsb.Length, "A new text.", new TsTextProps(FrenchWS));
            Assert.That(tsb.Text, Is.EqualTo("A new text."));
            Assert.That(tsb.RunCount, Is.EqualTo(1));
            Assert.That(GetWS(tsb, 0), Is.EqualTo(FrenchWS));
            int ichMin, ichLim;

            tsb.GetBoundsOfRun(0, out ichMin, out ichLim);
            Assert.That(ichMin, Is.EqualTo(0));
            Assert.That(ichLim, Is.EqualTo(tsb.Length));
        }