Ejemplo n.º 1
0
        public void ToMultilineOneInputTest()
        {
            const string originalString = "one two\n three fou\nr";
            var          s     = new StyledText(originalString, Color.Black);
            var          lines = StyledText.ToMultiline(s);

            Assert.AreEqual(3, lines.Count);
            Assert.AreEqual("one two", lines[0].Text);
            Assert.AreEqual(" three fou", lines[1].Text);
            Assert.AreEqual("r", lines[2].Text);

            foreach (var l in lines)
            {
                Assert.AreEqual(s.Color, l.Color);
            }
        }
Ejemplo n.º 2
0
        public void ToMultilineMultiInputSameLineTest()
        {
            const string originalString1 = "one \ntwo";
            const string originalString2 = " three fou\nr";
            var          s1    = new StyledText(originalString1, Color.Black);
            var          s2    = new StyledText(originalString2, Color.Black);
            var          lines = StyledText.ToMultiline(new StyledText[] { s1, s2 }, false);

            Assert.AreEqual(3, lines.Count);

            Assert.AreEqual("one ", lines[0][0].Text);

            Assert.AreEqual("two", lines[1][0].Text);
            Assert.AreEqual(" three fou", lines[1][1].Text);

            Assert.AreEqual("r", lines[2][0].Text);

            foreach (var l in lines)
            {
                Assert.AreEqual(s1.Color, l[0].Color);
                Assert.AreEqual(s2.Color, l[0].Color);
            }
        }
Ejemplo n.º 3
0
        public void ToMultiLineTest()
        {
            // Test removed since Font.DefaultFont in the testing framework seems to cause issues
            return;

#pragma warning disable 162
            var s1 = new StyledText("abcd", Color.Black);
            var s2 = new StyledText("\r123", Color.Black);
            var s3 = new StyledText("\nxyz", Color.Black);
            var s4 = new StyledText("\r\nqwe", Color.Black);

            var lines = new List <StyledText> {
                s1, s2, s3, s4
            };

            var r = StyledText.ToMultiline(lines, false, TestHelper.DefaultFont, 400);

            Assert.AreEqual("abcd", r[0][0].Text);
            Assert.AreEqual("123", r[1][0].Text);
            Assert.AreEqual("xyz", r[2][0].Text);
            Assert.AreEqual("qwe", r[3][0].Text);
#pragma warning restore 162
        }
Ejemplo n.º 4
0
        public void ToMultilineMultiInputDifferentLineTest()
        {
            const string originalString1 = "one \ntwo";
            const string originalString2 = "three fou\nr";
            const string originalString3 = "fi\r\nve";
            var          s1    = new StyledText(originalString1, Color.Black);
            var          s2    = new StyledText(originalString2, Color.Black);
            var          s3    = new StyledText(originalString3, Color.Black);
            var          lines = StyledText.ToMultiline(new StyledText[] { s1, s2, s3 }, true);

            Assert.AreEqual(6, lines.Count);
            Assert.AreEqual("one ", lines[0][0].Text);
            Assert.AreEqual("two", lines[1][0].Text);
            Assert.AreEqual("three fou", lines[2][0].Text);
            Assert.AreEqual("r", lines[3][0].Text);
            Assert.AreEqual("fi", lines[4][0].Text);
            Assert.AreEqual("ve", lines[5][0].Text);

            foreach (var l in lines)
            {
                Assert.AreEqual(s1.Color, l[0].Color);
                Assert.AreEqual(s2.Color, l[0].Color);
            }
        }