public void ShouldReportErrorIfIsDatabaseException() { var mockResponseHandler = new Mock <IMessageResponseHandler>(); var con = new PooledConnection(SocketConnectionTests.NewSocketConnection(handler: mockResponseHandler.Object)); mockResponseHandler.Setup(x => x.HasError).Returns(true); mockResponseHandler.Setup(x => x.Error).Returns(new DatabaseException("BLAH", "lalala")); var exception = Record.Exception(() => con.ReceiveOne()); exception.Should().BeOfType <DatabaseException>(); exception.Message.Should().Be("lalala"); con.HasUnrecoverableError.Should().BeTrue(); mockResponseHandler.VerifySet(x => x.Error = null, Times.Once); }