Exemplo n.º 1
0
        public void can_handle_multiple_regions()
        {
            var code = "this is some\n" +
                       "void t() {\n" +
                       " #region mybum\n" +
                       " int x \n " +
                       " #region nestedregion1\n" +
                       " var s = fred\n" +
                       "#endregion\n" +
                       " #region nestedregion2\n" +
                       " var s = fred\n" +
                       "#endregion\n" +

                       " #endregion\n" +
                       "}";
            var c = new RegionParser();


            var result = c.GetRegions(code);

            Assert.IsNotNull(result);
            Assert.AreEqual("mybum", result.First().Name);
            var expected = new string[] { "nestedregion1", "nestedregion2" };
            var actual   = result.First().NestedRegions.Select(x => x.Name);

            var actual2 = result.SelectMany(x => x.NestedRegions);

            CollectionAssert.AreEqual(expected, actual.ToList());
        }
Exemplo n.º 2
0
        public void can_handle_multiple_regions()
        {
            var code = "this is some\n" +
                     "void t() {\n" +
                     " #region mybum\n" +
                     " int x \n " +
                     " #region nestedregion1\n" +
                     " var s = fred\n" +
                     "#endregion\n" +
                     " #region nestedregion2\n" +
                     " var s = fred\n" +
                     "#endregion\n" +
                     
                     " #endregion\n" +
                     "}";
            var c = new RegionParser();


            var result = c.GetRegions(code);
            Assert.IsNotNull(result);
            Assert.AreEqual("mybum", result.First().Name);
            var expected = new string[] {"nestedregion1", "nestedregion2"};
            var actual = result.First().NestedRegions.Select(x => x.Name);
          
           var actual2 =  result.SelectMany(x => x.NestedRegions);
  CollectionAssert.AreEqual(expected, actual.ToList());
        }
Exemplo n.º 3
0
        private List <CodeRegion> Act(string filePath)
        {
            var tokenizer = TokenizerFactory.GetFor(DemoLanguage.Java);
            var parser    = new RegionParser(filePath, tokenizer);
            var result    = parser.GetRegions();

            return(result.ToList());
        }
Exemplo n.º 4
0
        public static DemoCodeBuilder Initialize(string filePath, DemoLanguage language)
        {
            var tokenizer = TokenizerFactory.GetFor(language);
            var parser    = new RegionParser(filePath, tokenizer);
            var regions   = parser.GetRegions().ToList();

            return(new DemoCodeBuilder(filePath, regions));
        }
Exemplo n.º 5
0
        public void can_find_simple_regions()
        {
            var code = "this is some\n" +
                       "void t() {\n" +
                       " #region mybum\n" +
                       " int x " +
                       " #endregion\n" +
                       "}";
            var c = new RegionParser();


            var result = c.GetRegions(code);

            Assert.IsNotNull(result);
        }
Exemplo n.º 6
0
        public void can_find_simple_regions()
        {
            var code = "this is some\n" +
                       "void t() {\n" +
                       " #region mybum\n" +
                       " int x " +
                       " #endregion\n" +
                       "}";
            var c = new RegionParser();
           

            var result = c.GetRegions(code);
            Assert.IsNotNull(result);

        }
Exemplo n.º 7
0
        public void can_handle_nested_regions()
        {
            var code = "this is some\n" +
                       "void t() {\n" +
                       " #region mybum\n" +
                       " int x \n" +
                       " #region nestedregion1\n" +
                       " var s = fred\n" +
                       "#endregion\n" +
                       " #endregion\n" +
                       "}";
            var c = new RegionParser();


            var result = c.GetRegions(code);
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count());
            Assert.AreEqual("mybum", result.First().Name);
            Assert.AreEqual("nestedregion1", result.First().NestedRegions.First().Name);
        }
Exemplo n.º 8
0
        public void can_handle_nested_regions()
        {
            var code = "this is some\n" +
                       "void t() {\n" +
                       " #region mybum\n" +
                       " int x \n" +
                       " #region nestedregion1\n" +
                       " var s = fred\n" +
                       "#endregion\n" +
                       " #endregion\n" +
                       "}";
            var c = new RegionParser();


            var result = c.GetRegions(code);

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count());
            Assert.AreEqual("mybum", result.First().Name);
            Assert.AreEqual("nestedregion1", result.First().NestedRegions.First().Name);
        }