public void Should_classify_without_settings() { var classifier = new ResponseCodeClassifier(); classifier.Classify("service", ResponseCode.Ok, 1.Seconds()).Should().Be(ResponseCodeClass.Success); classifier.Classify("service", ResponseCode.Conflict, 1.Seconds()).Should().Be(ResponseCodeClass.Warning); classifier.Classify("service", ResponseCode.InternalServerError, 1.Seconds()).Should().Be(ResponseCodeClass.Error); }
public void Should_classify_using_timeout_error_classification_threshold_setting(string service, int secondsLatency, ResponseCodeClass expected) { var serviceSettings = new ResponseCodeClassifierServiceSettings { TimeoutErrorClassificationThreshold = 5.Seconds() }; var settings = new ResponseCodeClassifierSettings { TimeoutErrorClassificationThreshold = 10.Seconds(), PerServiceSettings = new Dictionary <string, ResponseCodeClassifierServiceSettings> { ["service"] = serviceSettings } }; var classifier = new ResponseCodeClassifier(() => settings); classifier.Classify(service, ResponseCode.RequestTimeout, secondsLatency.Seconds()).Should().Be(expected); }
public void Should_classify_using_codes_from_settings(string service, ResponseCode code, ResponseCodeClass expected) { var serviceSettings = new ResponseCodeClassifierServiceSettings { SuccessCodes = new HashSet <ResponseCode> { ResponseCode.InternalServerError }, WarningCodes = new HashSet <ResponseCode> { ResponseCode.Created }, ErrorCodes = new HashSet <ResponseCode> { ResponseCode.Ok } }; var settings = new ResponseCodeClassifierSettings { SuccessCodes = new HashSet <ResponseCode> { ResponseCode.NotImplemented }, WarningCodes = new HashSet <ResponseCode> { ResponseCode.Accepted }, ErrorCodes = new HashSet <ResponseCode> { ResponseCode.NoContent }, PerServiceSettings = new Dictionary <string, ResponseCodeClassifierServiceSettings> { ["service"] = serviceSettings } }; var classifier = new ResponseCodeClassifier(() => settings); classifier.Classify(service, code, 1.Seconds()).Should().Be(expected); }