public void ClassifiesUsingOnlyEndOfChain() { ChainingClassifier classifier = new ChainingClassifier( statusCodes: null, handlers: null, HelperResponseClassifier.Instance); HttpMessage message = new HttpMessage(new MockRequest(), default); message.Response = new MockResponse(204); Assert.IsFalse(classifier.IsErrorResponse(message)); message.Response = new MockResponse(304); Assert.IsFalse(classifier.IsErrorResponse(message)); message.Response = new MockResponse(404); Assert.IsTrue(classifier.IsErrorResponse(message)); message.Response = new MockResponse(500); Assert.IsTrue(classifier.IsErrorResponse(message)); }
public void ClassifiesUsingHandlersAndEndOfChain() { ResponseClassificationHandler[] handlers = new ResponseClassificationHandler[] { new HeaderClassificationHandler(204, "ErrorCode", "Error"), new HeaderClassificationHandler(404, "ErrorCode", "NonError"), }; ChainingClassifier classifier = new ChainingClassifier( statusCodes: null, handlers: handlers, HelperResponseClassifier.Instance); HttpMessage message = new HttpMessage(new MockRequest(), default); var response = new MockResponse(204); response.AddHeader("ErrorCode", "Error"); message.Response = response; Assert.IsTrue(classifier.IsErrorResponse(message)); response = new MockResponse(304); response.AddHeader("ErrorCode", "Error"); message.Response = response; Assert.IsFalse(classifier.IsErrorResponse(message)); response = new MockResponse(404); response.AddHeader("ErrorCode", "Error"); message.Response = response; Assert.IsFalse(classifier.IsErrorResponse(message)); response = new MockResponse(500); response.AddHeader("ErrorCode", "Error"); message.Response = response; Assert.IsTrue(classifier.IsErrorResponse(message)); }