public void GetBytes_Should_Return_Value_Wehn_IsDbNull_Returns_False()
        {
            byte[] fakeResult     = new byte[1];
            var    mockDataReader = new Mock <IDataReader>();

            mockDataReader.Setup(x => x.GetOrdinal("bytes")).Returns(15);
            mockDataReader.Setup(x => x.IsDBNull(15)).Returns(false);
            mockDataReader.Setup(x => x.GetValue(15)).Returns(fakeResult);

            var sut    = new OptimizedDataReader(mockDataReader.Object);
            var result = sut.GetBytes("bytes");

            Assert.Equal(fakeResult, result);
            mockDataReader.Verify(x => x.GetOrdinal("bytes"), Times.Once);
            mockDataReader.Verify(x => x.GetValue(15), Times.Once);

            //Query the same row shouldn't call GetOrdinal
            mockDataReader.Invocations.Clear();
            var result2 = sut.GetBytes("bytes");

            Assert.Equal(fakeResult, result2);
            mockDataReader.Verify(x => x.GetOrdinal("bytes"), Times.Never);
            mockDataReader.Verify(x => x.GetValue(15), Times.Once);
        }
        public void GetBytes_Should_Return_Null_Wehn_IsDbNull_Returns_True()
        {
            var mockDataReader = new Mock <IDataReader>();

            mockDataReader.Setup(x => x.GetOrdinal("bytes")).Returns(15);
            mockDataReader.Setup(x => x.IsDBNull(15)).Returns(true);
            mockDataReader.Setup(x => x.GetValue(15));

            var sut    = new OptimizedDataReader(mockDataReader.Object);
            var result = sut.GetBytes("bytes");

            Assert.Null(result);
            mockDataReader.Verify(x => x.GetOrdinal("bytes"), Times.Once);
            mockDataReader.Verify(x => x.IsDBNull(15), Times.Once);
            mockDataReader.Verify(x => x.GetString(15), Times.Never);
        }