Exemplo n.º 1
0
        public void Text_Line_Should_Generate_Text_Runs()
        {
            using var app = UnitTestApplication.Start(new TestServices().With(
                                                          renderInterface: new MockPlatformRenderInterface(),
                                                          fontManagerImpl: new MockFontManagerImpl(),
                                                          formattedTextImpl: Mock.Of <IFormattedTextImpl>()));

            SimpleTextSource textSource = new SimpleTextSource("hello", CreateDefaultTextProperties());

            TextLineImpl textLine = TextLineImpl.Create(
                CreateDefaultParagraphProperties(), 0, 5, textSource);

            Assert.AreEqual(2, textLine.LineRuns.Length);
            Assert.AreEqual("hello", textLine.LineRuns[0].StringRange.ToString());
            Assert.IsTrue(textLine.LineRuns[1].IsEnd);
        }
Exemplo n.º 2
0
        public void Text_Line_Should_Wrap_In_Two_Runs_Option_Enabled()
        {
            using var app = UnitTestApplication.Start(new TestServices().With(
                                                          renderInterface: new MockPlatformRenderInterface(),
                                                          fontManagerImpl: new MockFontManagerImpl(),
                                                          formattedTextImpl: Mock.Of <IFormattedTextImpl>()));

            SimpleTextSource s = new SimpleTextSource(
                "hello world",
                CreateDefaultTextProperties());

            TextParagraphProperties paraProps = CreateDefaultParagraphProperties();

            paraProps.TextWrapping = TextWrapping.Wrap;

            TextLineImpl textLine = TextLineImpl.Create(
                paraProps, 0, MockGlyphTypeface.GlyphAdvance * 7, s);

            Assert.AreEqual("hello ".Length, textLine.LineRuns[0].Length);
        }
Exemplo n.º 3
0
        public void Tab_Block_Should_Split_Runs()
        {
            using var app = UnitTestApplication.Start(new TestServices().With(
                                                          renderInterface: new MockPlatformRenderInterface(),
                                                          fontManagerImpl: new MockFontManagerImpl(),
                                                          formattedTextImpl: Mock.Of <IFormattedTextImpl>()));

            SimpleTextSource s = new SimpleTextSource(
                "\t\t",
                CreateDefaultTextProperties());

            TextLineImpl textLine = TextLineImpl.Create(
                CreateDefaultParagraphProperties(), 0, 2, s);

            var textRuns = textLine.GetTextRuns();

            Assert.AreEqual(3, textRuns.Count);
            Assert.IsTrue(textLine.LineRuns[0].IsTab);
            Assert.IsTrue(textLine.LineRuns[1].IsTab);
            Assert.IsTrue(textLine.LineRuns[2].IsEnd);
        }