/// <summary>
        /// Attempts to match the line with each regex specified by the current state
        /// </summary>
        /// <param name="state">Current state</param>
        /// <param name="logData">Input line</param>
        /// <returns>True if a match occurs</returns>
        private bool AttemptMatch(ITestResultParserState state, LogData logData)
        {
            foreach (var regexActionPair in state.RegexesToMatch)
            {
                try
                {
                    var match = regexActionPair.Regex.Match(logData.Line);
                    if (match.Success)
                    {
                        // Reset this value on a match
                        _stateContext.LinesWithinWhichMatchIsExpected = -1;

                        _currentState = (JasmineParserStates)regexActionPair.MatchAction(match, _stateContext);
                        return(true);
                    }
                }
                catch (RegexMatchTimeoutException)
                {
                    Logger.Warning($"JasmineTestResultParser : AttemptMatch : failed due to timeout while trying to match { regexActionPair.Regex.ToString() } at line {logData.LineNumber}");
                    Telemetry.AddAndAggregate("RegexTimeout", new List <string> {
                        regexActionPair.Regex.ToString()
                    }, JasmineTelemetryConstants.EventArea);
                }
            }

            state.PeformNoPatternMatchedAction(logData.Line, _stateContext);

            return(false);
        }
        /// <summary>
        /// Detailed constructor where specified logger and telemetry data collector are initialized along with test run manager
        /// </summary>
        /// <param name="testRunPublisher"></param>
        /// <param name="diagnosticDataCollector"></param>
        /// <param name="telemetryDataCollector"></param>
        public JasmineTestResultParser(ITestRunManager testRunManager, ITraceLogger logger, ITelemetryDataCollector telemetryDataCollector) :
            base(testRunManager, logger, telemetryDataCollector)
        {
            Logger.Info("JasmineTestResultParser : Starting jasmine test result parser.");
            Telemetry.AddOrUpdate(JasmineTelemetryConstants.Initialize, true, JasmineTelemetryConstants.EventArea);

            // Initialize the starting state of the parser
            var testRun = new TestRun($"{Name}/{Version}", "Jasmine", 1);

            _stateContext = new JasmineParserStateContext(testRun);
            _currentState = JasmineParserStates.ExpectingTestRunStart;
        }
        /// <summary>
        /// Used to reset the parser including the test run and context
        /// </summary>
        private void ResetParser()
        {
            // Start a new TestRun
            var newTestRun = new TestRun($"{Name}/{Version}", "Jasmine", _stateContext.TestRun.TestRunId + 1);

            // Set state to ExpectingTestResults
            _currentState = JasmineParserStates.ExpectingTestRunStart;

            // Refresh the context
            _stateContext.Initialize(newTestRun);

            Logger.Info("JasmineTestResultParser : Successfully reset the parser.");
        }