コード例 #1
0
        public void TextProviderTest()
        {
            using (TextProvider <object> text = new TextProvider <object>())
            {
                AssertTextProvider("", text);

                Assert.AreEqual(new TextPosition(0, 15), text.Edit(new TextPosition(0, 0), new TextPosition(0, 0), "Vczh is genius!"));
                AssertTextProvider("Vczh is genius!", text);

                Assert.AreEqual(new TextPosition(1, 15), text.Edit(new TextPosition(0, 15), new TextPosition(0, 15), "", "Vczh is clever!"));
                AssertTextProvider("Vczh is genius!\r\nVczh is clever!", text);

                Assert.AreEqual(new TextPosition(0, 6), text.Edit(new TextPosition(0, 6), new TextPosition(1, 6)));
                AssertTextProvider("Vczh is clever!", text);
            }
            using (TextProvider <object> text = new TextProvider <object>())
            {
                Assert.AreEqual(new TextPosition(3, 6), text.Edit(new TextPosition(0, 0), new TextPosition(0, 0), "ABCDEFG", "HIJKLMN", "OPQRST", "UVWXYZ"));
                AssertTextProvider("ABCDEFG\r\nHIJKLMN\r\nOPQRST\r\nUVWXYZ", text);

                Assert.AreEqual(new TextPosition(0, 7), text.Edit(new TextPosition(0, 4), new TextPosition(2, 3), "..."));
                AssertTextProvider("ABCD...RST\r\nUVWXYZ", text);

                Assert.AreEqual(new TextPosition(2, 3), text.Edit(new TextPosition(0, 4), new TextPosition(0, 7), "EFG", "HIJKLMN", "OPQ"));
                AssertTextProvider("ABCDEFG\r\nHIJKLMN\r\nOPQRST\r\nUVWXYZ", text);

                Assert.AreEqual(new TextPosition(1, 3), text.Edit(new TextPosition(0, 4), new TextPosition(2, 3), "...", "???"));
                AssertTextProvider("ABCD...\r\n???RST\r\nUVWXYZ", text);
            }
        }