public IncidentRegexParser(
     IIncidentRegexParsingHandler handler,
     ILogger <IncidentRegexParser> logger)
 {
     _handler = handler ?? throw new ArgumentNullException(nameof(_handler));
     _logger  = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Beispiel #2
0
        public static void AssertTryParseAffectedComponentStatus(
            IIncidentRegexParsingHandler handler,
            Incident incident,
            bool success,
            ComponentStatus expectedAffectedComponentStatus = ComponentStatus.Up)
        {
            var affectedComponentStatus = ComponentStatus.Up;
            var result =
                TryGetMatch(incident.Title, handler.RegexPattern, out var match) &&
                handler.TryParseAffectedComponentStatus(incident, match.Groups, out affectedComponentStatus);

            Assert.Equal(success, result);
            if (!result)
            {
                return;
            }

            Assert.Equal(expectedAffectedComponentStatus, affectedComponentStatus);
        }
Beispiel #3
0
        public static void AssertTryParseAffectedComponentPath(
            IIncidentRegexParsingHandler handler,
            Incident incident,
            bool success,
            string expectedAffectedComponentPath = null)
        {
            var affectedComponentPath = string.Empty;
            var result =
                TryGetMatch(incident.Title, handler.RegexPattern, out var match) &&
                handler.TryParseAffectedComponentPath(incident, match.Groups, out affectedComponentPath);

            Assert.Equal(success, result);
            if (!result)
            {
                return;
            }

            Assert.Equal(expectedAffectedComponentPath, affectedComponentPath);
        }