Ejemplo n.º 1
0
        public IList<TestModel> Parse()
        {
            List<TestModel> result = new List<TestModel>();

            //// Load test from yaml file
            const Int32 BufferSize = 128;
            using (var fileStream = File.OpenRead(_filePath))
            using (var streamReader = new StreamReader(fileStream, Encoding.UTF8, true, BufferSize))
            {
                string line;
                while ((line = streamReader.ReadLine()) != null)
                {

                    if (line.Contains(DescriptionTag))
                    {
                        var test = new TestModel();
                        test.Description = line.Split(':').LastOrDefault();
                        result.Add(test);
                    }

                    // Process line
                   // FindTest(line,streamReader);
                }
            }

            return result;
        }
Ejemplo n.º 2
0
        private bool FindScenario(StreamReader streamReader, TestModel result)
        {
            string line;
            while ((line = streamReader.ReadLine()) != null)
            {
                if (line.Contains(ScenarioTag))
                {
                    return true;
                }
            }

            return false;
        }
Ejemplo n.º 3
0
        private TestModel FindTest(string line, StreamReader streamReader)
        {
            var result = new TestModel();
            if (string.IsNullOrEmpty(FindDescription(streamReader)))
            {
                return result;
            }

            if (FindScenario(streamReader, result))
            {
                FindTests(streamReader, result);
            }

            return result;
        }
Ejemplo n.º 4
0
        private void FindUnitTestCollection(StreamReader streamReader, TestModel result)
        {
            result.Tests = new List<UnitTestModel>();
            string line;
            while ((line = streamReader.ReadLine()) != null)
            {
                switch (GetKeyWord(line))
                {
                    case GivenTag:

                    case WhenTag:
                    case ThenTag:
                    case "":
                        break;
                    case ArrayTag:
                        result.Tests.Add(new UnitTestModel());
                        break;
                    case DescriptionTag:
                        return;
                    case ScenarioTag:
                        return;
                }
            }
        }
Ejemplo n.º 5
0
        private void FindTests(StreamReader streamReader, TestModel result)
        {
            string line = streamReader.ReadLine();
            if(line != null)
            {
                switch (line)
                {
                    case "-":
                        FindUnitTestCollection(streamReader, result);
                        break;
                    case WhenTag:
                    case GivenTag:
                    case ThenTag:
                        break;
                    default:
                        throw new  Exception( String.Format("Invalid line --> {0}", line));

                }
                if (line.Contains(DescriptionTag))
                {
                    result.Description = line.Split(':').LastOrDefault();

                }
            }
        }