GivenDefaultHandledExceptionWithCustomMap_WhenMapped_ThenReturnsHttpStatusWithProperMessageFromCustomMap() { //Given const string message = "Message"; var exception = new NotImplementedException(message); ExceptionToHttpStatusMapper.RegisterCustomMap <NotImplementedException>( exc => HttpStatusCodeInfo.Create(HttpStatusCode.BadRequest, "CustomMessage")); //When var codeInfo = ExceptionToHttpStatusMapper.Map(exception); //Then codeInfo.Code.Should().Be(HttpStatusCode.BadRequest); codeInfo.Message.Should().Be("CustomMessage"); }
public void GivenOtherTypeExceptionWithCustomMap_WhenMapped_ThenReturnsHttpStatusWithProperMessageFromCustomMap() { //Given var message = "Message"; var exception = new ArgumentNullException(message); ExceptionToHttpStatusMapper.RegisterCustomMap <ArgumentNullException>( exc => HttpStatusCodeInfo.Create(HttpStatusCode.BadRequest, "CustomMessage")); //When var codeInfo = ExceptionToHttpStatusMapper.Map(exception); //Then codeInfo.Code.Should().Be(HttpStatusCode.BadRequest); codeInfo.Message.Should().Be("CustomMessage"); }