Esempio n. 1
0
        public void TestModelOps()
        {
            var doc = new List <string>
            {
                "using abc.def;",
                "",
                "namespace abc.def",
                "{",
                "// hello",
                "\tpublic class Startup",      // POS 5
                "\t{",
                "\t\tpublic Startup(Thing x)", // POS 7
                "\t\t{",
                "\t\t\tblah blah",
                "\t\t\tvar x = \"321\";",
                "\t\t\t",
                "\t\t\tif (check)",
                "\t\t\t{",
                "\t\t\t\blah",
                "\t\t\t}",
                "\t\t}",
                "",
                "\t\ttpublic void Thingy()", // POS 18
                "\t\t{",
                "\t\t}",
                "\t}",
                "}"
            };

            var fm = new FileModel(doc);

            bool found = fm.FindLineContains("Startup(");

            Assert.Equal(7, fm.LineNum);

            fm.Jump(1);
            string wordFound = fm.FindLineContainsAny(new string[] { "public", "private", "protected" });

            Assert.Equal(18, fm.LineNum);
            Assert.Equal("public", wordFound);

            fm.FindPrevLineIs("}");
            Assert.Equal(16, fm.LineNum);

            fm.ToTop();

            fm.FindLineContains("Startup(");
            fm.FindEndOfMethod();
            Assert.Equal(15, fm.LineNum);

            fm.FindLineContains("Thingy(");
            fm.FindEndOfMethod();
            Assert.Equal(19, fm.LineNum);
        }