Example #1
0
        public void should_export_jt_with_nested_jts()
        {
            var fixtureFileFullName = TestUtils.GetFixtureFileFullName("JT\\Fixtures\\nested-spec.es6");

            var           jtManager = new JTManager();
            List <UTInfo> utInfos   = jtManager.Export(fixtureFileFullName);

            Assert.Equal(2, utInfos.Count);

            UTInfo topUtInfo1 = utInfos.First();

            Assert.Equal("top describe 1", topUtInfo1.Description);
            Assert.Equal("top it 1.1", topUtInfo1.ThenList[0].Description);
            Assert.Equal("top it 1.2", topUtInfo1.ThenList[1].Description);

            UTInfo child1 = topUtInfo1.Children.First();

            Assert.Equal("describe 1", child1.Description);
            Assert.Equal("it 1.1", child1.ThenList[0].Description);
            Assert.Equal("it 1.2", child1.ThenList[1].Description);

            Assert.Equal(1, child1.Children.Count);
            UTInfo grandson = child1.Children.First();

            Assert.Equal("describe 1.3", grandson.Description);
            Assert.Equal("it 1.3.1", grandson.ThenList[0].Description);
            Assert.Equal("it 1.3.2", grandson.ThenList[1].Description);

            UTInfo child2 = topUtInfo1.Children.Last();

            Assert.Equal("describe 2", child2.Description);
            Assert.Equal("it 2.1", child2.ThenList[0].Description);
            Assert.Equal("it 2.2", child2.ThenList[1].Description);

            UTInfo topUtInfo2 = utInfos.Last();

            Assert.Equal("top describe 2", topUtInfo2.Description);
            Assert.Equal("top it 2.1", topUtInfo2.ThenList[0].Description);
            Assert.Equal("top it 2.2", topUtInfo2.ThenList[1].Description);
        }
        public void should_export_jt_with_correct_levels()
        {
            var fixtureFileFullName = TestUtils.GetFixtureFileFullName("JT\\Fixtures\\space-and-tab-spec.es6");

            var           jtManager = new JTManager();
            List <UTInfo> utInfos   = jtManager.Export(fixtureFileFullName);

            Assert.Equal(1, utInfos.Count);

            UTInfo topUtInfo = utInfos.Single();

            Assert.Equal(1, topUtInfo.Children.Count);

            UTInfo child = topUtInfo.Children.Single();

            Assert.Equal("describe with 3 spaces and 1 tab", child.Description);
            Assert.Equal(1, child.Children.Count);

            UTInfo grandson = child.Children.Single();

            Assert.Equal("describe with 5 spaces and 1 tab", grandson.Description);
        }
Example #3
0
        public void when_export_mspec_with_nested_spec()
        {
            var           mSpecManager = new MSpecManager();
            List <UTInfo> utInfos      =
                mSpecManager.Export(
                    TestUtils.GetFixtureFileFullName("MSpec\\Fixtures\\MSpecWithNested.txt"));

            Assert.Equal(1, utInfos.Count);
            UTInfo topLevelUtInfo = utInfos.Single();

            Assert.Equal(0, topLevelUtInfo.WhenList.Count);
            Assert.Equal(0, topLevelUtInfo.ThenList.Count);
            Assert.Equal(2, topLevelUtInfo.Children.Count);

            UTInfo nested1UtInfo = topLevelUtInfo.Children.First();

            Assert.Equal(1, nested1UtInfo.WhenList.Count);
            Assert.Equal(2, nested1UtInfo.ThenList.Count);
            Assert.Equal(0, nested1UtInfo.Children.Count);

            UTInfo nested2UtInfo = topLevelUtInfo.Children.Last();

            Assert.Equal(0, nested2UtInfo.WhenList.Count);
            Assert.Equal(0, nested2UtInfo.ThenList.Count);
            Assert.Equal(2, nested2UtInfo.Children.Count);

            UTInfo nested3UtInfo = nested2UtInfo.Children.First();

            Assert.Equal(2, nested3UtInfo.WhenList.Count);
            Assert.Equal(2, nested3UtInfo.ThenList.Count);
            Assert.Equal(0, nested3UtInfo.Children.Count);

            UTInfo nested4UtInfo = nested2UtInfo.Children.Last();

            Assert.Equal(1, nested4UtInfo.WhenList.Count);
            Assert.Equal(2, nested4UtInfo.ThenList.Count);
            Assert.Equal(0, nested4UtInfo.Children.Count);
        }
Example #4
0
        public List <UTInfo> Export(string fullFileName)
        {
            var rootUtInfo = new UTInfo(fullFileName);

            using (var streamReader = new StreamReader(fullFileName))
            {
                while (!streamReader.EndOfStream)
                {
                    string currentLine = streamReader.ReadLine();

                    if (currentLine.IsComment() || !currentLine.IsUsefulMSpecStatement())
                    {
                        continue;
                    }

                    int currentLevel = currentLine.GetLevel();
                    if (currentLine.IsClass())
                    {
                        AddClass(fullFileName, rootUtInfo, currentLevel, currentLine);
                    }

                    if (currentLine.IsBecause())
                    {
                        AddBecause(rootUtInfo, currentLevel, currentLine);
                    }

                    if (currentLine.IsIt())
                    {
                        AddIt(rootUtInfo, currentLevel, currentLine);
                    }
                }
            }

            rootUtInfo.ClearEmptyChildren();

            return(rootUtInfo.Children);
        }
Example #5
0
 private UTInfo GetItParent(UTInfo utInfo, int currentLevel)
 {
     return(GetDescribeParent(utInfo, currentLevel));
 }
Example #6
0
 private UTInfo GetFieldParentClass(UTInfo utInfo, int currentLevel)
 {
     return(GetClassParent(utInfo, currentLevel));
 }
Example #7
0
        private void AddBecause(UTInfo rootUtInfo, int currentLevel, string currentLine)
        {
            UTInfo parentClass = GetFieldParentClass(rootUtInfo, currentLevel);

            parentClass.WhenList.Add(currentLine.ToBecause());
        }