Add string overloads to DbDataReader.Get*()
authorEssam Almohammadi <eamhm21@hotmail.com>
Sat, 9 Feb 2019 10:55:56 +0000 (11:55 +0100)
committerArthur Vickers <ajcvickers@hotmail.com>
Tue, 26 Feb 2019 20:58:44 +0000 (12:58 -0800)
Implement dotnet/corefx#31595

Commit migrated from https://github.com/dotnet/corefx/commit/b30fc2b4ee302e449e3580ae39cb083a76b813c9

src/libraries/System.Data.Common/ref/System.Data.Common.csproj
src/libraries/System.Data.Common/ref/System.Data.Common.netcoreapp.cs [new file with mode: 0644]
src/libraries/System.Data.Common/src/System.Data.Common.csproj
src/libraries/System.Data.Common/src/System/Data/Common/DbDataReader.cs
src/libraries/System.Data.Common/src/System/Data/Common/DbDataReader.netcoreapp.cs [new file with mode: 0644]
src/libraries/System.Data.Common/tests/System.Data.Common.Tests.csproj
src/libraries/System.Data.Common/tests/System/Data/Common/DbDataReaderMock.cs
src/libraries/System.Data.Common/tests/System/Data/Common/DbDataReaderTest.cs
src/libraries/System.Data.Common/tests/System/Data/Common/DbDataReaderTest.netcoreapp.cs [new file with mode: 0644]

index 9a5fad8..0fabea2 100644 (file)
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <ProjectGuid>{D2DB0D6F-F65E-4174-B31E-27DC03137118}</ProjectGuid>
     <NoWarn>$(NoWarn);0618</NoWarn>
@@ -7,6 +7,7 @@
   <ItemGroup>
     <Compile Include="System.Data.Common.cs" />
     <Compile Include="System.Data.Common.manual.cs" />
+    <Compile Include="System.Data.Common.netcoreapp.cs" Condition="'$(TargetsNetCoreApp)' == 'true'" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\System.Collections.NonGeneric\ref\System.Collections.NonGeneric.csproj" />
diff --git a/src/libraries/System.Data.Common/ref/System.Data.Common.netcoreapp.cs b/src/libraries/System.Data.Common/ref/System.Data.Common.netcoreapp.cs
new file mode 100644 (file)
index 0000000..b377b1b
--- /dev/null
@@ -0,0 +1,63 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+// ------------------------------------------------------------------------------
+// Changes to this file must follow the http://aka.ms/api-review process.
+// ------------------------------------------------------------------------------
+
+namespace System.Data.Common
+{
+    public abstract partial class DbDataReader
+    {
+        public bool GetBoolean(string name) => throw null;
+
+        public byte GetByte(string name) => throw null;
+
+        public long GetBytes(string name, long dataOffset, byte[] buffer, int bufferOffset, int length) => throw null;
+
+        public char GetChar(string name) => throw null;
+
+        public long GetChars(string name, long dataOffset, char[] buffer, int bufferOffset, int length) => throw null;
+
+        [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(1))]
+        public System.Data.Common.DbDataReader GetData(string name) => throw null;
+
+        public string GetDataTypeName(string name) => throw null;
+
+        public System.DateTime GetDateTime(string name) => throw null;
+
+        public decimal GetDecimal(string name) => throw null;
+
+        public double GetDouble(string name) => throw null;
+
+        public System.Type GetFieldType(string name) => throw null;
+
+        public T GetFieldValue<T>(string name) => throw null;
+
+        public float GetFloat(string name) => throw null;
+
+        public System.Guid GetGuid(string name) => throw null;
+
+        public short GetInt16(string name) => throw null;
+
+        public int GetInt32(string name) => throw null;
+
+        public long GetInt64(string name) => throw null;
+
+        [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(1))]
+        public System.Type GetProviderSpecificFieldType(string name) => throw null;
+
+        [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(1))]
+        public object GetProviderSpecificValue(string name) => throw null;
+
+        public System.IO.Stream GetStream(string name) => throw null;
+
+        public string GetString(string name) => throw null;
+
+        public System.IO.TextReader GetTextReader(string name) => throw null;
+
+        public object GetValue(string name) => throw null;
+
+        public bool IsDBNull(string name) => throw null;
+    }
+}
index c2ccd33..c870306 100644 (file)
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <ProjectGuid>{29EF8D53-8E84-4E49-B90F-5950A2FE7D54}</ProjectGuid>
     <AssemblyName>System.Data.Common</AssemblyName>
       <SubType>Component</SubType>
     </Compile>
     <Compile Include="System\Data\Common\DbDataReader.cs" />
+    <Compile Include="System\Data\Common\DbDataReader.netcoreapp.cs" Condition="'$(TargetsNetCoreApp)' == 'true'" />
     <Compile Include="System\Data\Common\DbDataReaderExtensions.cs" />
     <Compile Include="System\Data\Common\DbDataRecord.cs" />
     <Compile Include="System\Data\Common\DbDataSourceEnumerator.cs" />
index ff30a41..49cf9cd 100644 (file)
@@ -10,7 +10,7 @@ using System.Threading;
 
 namespace System.Data.Common
 {
-    public abstract class DbDataReader : MarshalByRefObject, IDataReader, IEnumerable
+    public abstract partial class DbDataReader : MarshalByRefObject, IDataReader, IEnumerable
     {
         protected DbDataReader() : base() { }
 
diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DbDataReader.netcoreapp.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DbDataReader.netcoreapp.cs
new file mode 100644 (file)
index 0000000..2ec616a
--- /dev/null
@@ -0,0 +1,65 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.ComponentModel;
+using System.IO;
+
+namespace System.Data.Common
+{
+    public abstract partial class DbDataReader
+    {
+        public bool GetBoolean(string name) => GetBoolean(GetOrdinal(name));
+
+        public byte GetByte(string name) => GetByte(GetOrdinal(name));
+
+        public long GetBytes(string name, long dataOffset, byte[] buffer, int bufferOffset, int length) =>
+            GetBytes(GetOrdinal(name), dataOffset, buffer, bufferOffset, length);
+
+        public char GetChar(string name) => GetChar(GetOrdinal(name));
+
+        public long GetChars(string name, long dataOffset, char[] buffer, int bufferOffset, int length) =>
+            GetChars(GetOrdinal(name), dataOffset, buffer, bufferOffset, length);
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public DbDataReader GetData(string name) => GetData(GetOrdinal(name));
+
+        public string GetDataTypeName(string name) => GetDataTypeName(GetOrdinal(name));
+
+        public DateTime GetDateTime(string name) => GetDateTime(GetOrdinal(name));
+
+        public decimal GetDecimal(string name) => GetDecimal(GetOrdinal(name));
+
+        public double GetDouble(string name) => GetDouble(GetOrdinal(name));
+
+        public Type GetFieldType(string name) => GetFieldType(GetOrdinal(name));
+
+        public T GetFieldValue<T>(string name) => GetFieldValue<T>(GetOrdinal(name));
+
+        public float GetFloat(string name) => GetFloat(GetOrdinal(name));
+
+        public Guid GetGuid(string name) => GetGuid(GetOrdinal(name));
+
+        public short GetInt16(string name) => GetInt16(GetOrdinal(name));
+
+        public int GetInt32(string name) => GetInt32(GetOrdinal(name));
+
+        public long GetInt64(string name) => GetInt64(GetOrdinal(name));
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Type GetProviderSpecificFieldType(string name) => GetProviderSpecificFieldType(GetOrdinal(name));
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public object GetProviderSpecificValue(string name) => GetProviderSpecificValue(GetOrdinal(name));
+
+        public Stream GetStream(string name) => GetStream(GetOrdinal(name));
+
+        public string GetString(string name) => GetString(GetOrdinal(name));
+
+        public TextReader GetTextReader(string name) => GetTextReader(GetOrdinal(name));
+
+        public object GetValue(string name) => GetValue(GetOrdinal(name));
+
+        public bool IsDBNull(string name) => IsDBNull(GetOrdinal(name));
+    }
+}
index 4e1ce47..eff75c1 100644 (file)
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <ProjectGuid>{B473F77D-4168-4123-932A-E88020B768FA}</ProjectGuid>
     <NoWarn>0168,0169,0414,0219,0649</NoWarn>
@@ -19,6 +19,7 @@
     <Compile Include="System\Data\Common\DbDataAdapterTest.cs" />
     <Compile Include="System\Data\Common\DbDataReaderMock.cs" />
     <Compile Include="System\Data\Common\DbDataReaderTest.cs" />
+    <Compile Include="System\Data\Common\DbDataReaderTest.netcoreapp.cs" Condition="'$(TargetsNetCoreApp)' == 'true'" />
     <Compile Include="System\Data\Common\DbTransactionTest.cs" />
     <Compile Include="System\Data\Common\RowUpdatedEventArgsTest.cs" />
     <Compile Include="System\Data\Common\RowUpdatingEventArgsTest.cs" />
index 63b5ae9..84b8763 100644 (file)
@@ -66,12 +66,12 @@ namespace System.Data.Tests.Common
 
         public override bool GetBoolean(int ordinal)
         {
-            throw new NotImplementedException();
+            return (bool)GetValue(ordinal);
         }
 
         public override byte GetByte(int ordinal)
         {
-            throw new NotImplementedException();
+            return (byte)GetValue(ordinal);
         }
 
         public override long GetBytes(int ordinal, long dataOffset, byte[] buffer, int bufferOffset, int length)
@@ -90,12 +90,21 @@ namespace System.Data.Tests.Common
 
         public override char GetChar(int ordinal)
         {
-            throw new NotImplementedException();
+            return (char)GetValue(ordinal);
         }
 
         public override long GetChars(int ordinal, long dataOffset, char[] buffer, int bufferOffset, int length)
         {
-            throw new NotImplementedException();
+            object value = GetValue(ordinal);
+            if (value == DBNull.Value)
+            {
+                return 0;
+            }
+
+            char[] data = value.ToString().ToCharArray();
+            long bytesToRead = Math.Min(data.Length - dataOffset, length);
+            Array.Copy(data, dataOffset, buffer, bufferOffset, bytesToRead);
+            return bytesToRead;
         }
 
         public override string GetDataTypeName(int ordinal)
@@ -105,17 +114,17 @@ namespace System.Data.Tests.Common
 
         public override DateTime GetDateTime(int ordinal)
         {
-            throw new NotImplementedException();
+            return (DateTime)GetValue(ordinal);
         }
 
         public override decimal GetDecimal(int ordinal)
         {
-            throw new NotImplementedException();
+            return (decimal)GetValue(ordinal);
         }
 
         public override double GetDouble(int ordinal)
         {
-            throw new NotImplementedException();
+            return (double)GetValue(ordinal);
         }
 
         public override global::System.Collections.IEnumerator GetEnumerator()
@@ -130,37 +139,48 @@ namespace System.Data.Tests.Common
 
         public override float GetFloat(int ordinal)
         {
-            throw new NotImplementedException();
+            return (float)GetValue(ordinal);
         }
 
         public override Guid GetGuid(int ordinal)
         {
-            throw new NotImplementedException();
+            return (Guid)GetValue(ordinal);
         }
 
         public override short GetInt16(int ordinal)
         {
-            throw new NotImplementedException();
+            return (short)GetValue(ordinal);
         }
 
         public override int GetInt32(int ordinal)
         {
-            throw new NotImplementedException();
+            return (int)GetValue(ordinal);
         }
 
         public override long GetInt64(int ordinal)
         {
-            throw new NotImplementedException();
+            return (long)GetValue(ordinal);
         }
 
         public override string GetName(int ordinal)
         {
-            throw new NotImplementedException();
+            return _testDataTable.Columns[ordinal].ColumnName;
         }
 
         public override int GetOrdinal(string name)
         {
-            throw new NotImplementedException();
+            // TODO: not efficient; needs to cache the columns
+            for (var i = 0; i < _testDataTable.Columns.Count; ++i)
+            {
+                var columnName = _testDataTable.Columns[i].ColumnName;
+
+                if (columnName.Equals(name, StringComparison.OrdinalIgnoreCase))
+                {
+                    return i;
+                }
+            }
+
+            return -1;
         }
 
         public override DataTable GetSchemaTable()
index f7aea15..4bc081d 100644 (file)
@@ -26,115 +26,152 @@ using Xunit;
 
 namespace System.Data.Tests.Common
 {
-    public class DbDataReaderTest
+    public partial class DbDataReaderTest
     {
-        private DbDataReaderMock _dataReader;
+        private readonly DbDataReaderMock _dataReader;
 
         public DbDataReaderTest()
         {
-            //Setup test data table
+            // Setup test data table
             DataTable testData = new DataTable();
             testData.Columns.Add("text_col", typeof(string));
             testData.Columns.Add("binary_col", typeof(byte[]));
-
-            testData.Rows.Add("row_1", new byte[] { 0xde, 0xad, 0xbe, 0xef });
+            testData.Columns.Add("boolean_col", typeof(bool));
+            testData.Columns.Add("byte_col", typeof(byte));
+            testData.Columns.Add("char_col", typeof(char));
+            testData.Columns.Add("datetime_col", typeof(DateTime));
+            testData.Columns.Add("decimal_col", typeof(decimal));
+            testData.Columns.Add("double_col", typeof(double));
+            testData.Columns.Add("float_col", typeof(float));
+            testData.Columns.Add("guid_col", typeof(Guid));
+            testData.Columns.Add("short_col", typeof(short));
+            testData.Columns.Add("int_col", typeof(int));
+            testData.Columns.Add("long_col", typeof(long));
+            testData.Columns.Add("dbnull_col", typeof(object));
+
+            var values = new object[14];
+            values[0] = ".NET";
+            values[1] = new byte[] { 0xDE, 0xAD, 0xBE, 0xEF };
+            values[2] = true;
+            values[3] = 0x00;
+            values[4] = 'E';
+            values[5] = new DateTime(2016, 6, 27);
+            values[6] = 810.72m;
+            values[7] = Math.PI;
+            values[8] = 776.90f;
+            values[9] = Guid.Parse("893e4fe8-299a-465a-a600-3cd4ad91629a");
+            values[10] = 12345;
+            values[11] = 1234567890;
+            values[12] = 1234567890123456789;
+            values[13] = DBNull.Value;
+
+            testData.Rows.Add("row_1", new byte[] { 0xDE, 0xAD, 0xBE, 0xEF });
             testData.Rows.Add("row_2", DBNull.Value);
             testData.Rows.Add("row_3", new byte[] { 0x00 });
+            testData.Rows.Add(values);
 
             _dataReader = new DbDataReaderMock(testData);
 
-            Assert.Equal(3, testData.Rows.Count);
+            Assert.Equal(4, testData.Rows.Count);
+        }
+
+        [Fact]
+        public void GetFieldValueTest()
+        {
+            // First row
+            _dataReader.Read();
+
+            Assert.Equal("row_1", _dataReader.GetFieldValue<string>(0));
+
+            byte[] expected_data = new byte[] { 0xDE, 0xAD, 0xBE, 0xEF };
+            byte[] actual_data = _dataReader.GetFieldValue<byte[]>(1);
+            Assert.Equal(expected_data.Length, actual_data.Length);
+            for (int i = 0; i < expected_data.Length; i++)
+            {
+                Assert.Equal(expected_data[i], actual_data[i]);
+            }
+
+            // Second row where data row column value is DBNull
+            _dataReader.Read();
+            Assert.Equal("row_2", _dataReader.GetFieldValue<string>(0));
+            Assert.Throws<InvalidCastException>(() => _dataReader.GetFieldValue<byte[]>(1));
+
+            // Third row
+            _dataReader.Read();
+            Assert.Equal("row_3", _dataReader.GetFieldValue<string>(0));
+
+            expected_data = new byte[] { 0x00 };
+            actual_data = _dataReader.GetFieldValue<byte[]>(1);
+            Assert.Equal(expected_data.Length, actual_data.Length);
+            Assert.Equal(expected_data[0], actual_data[0]);
+        }
+
+        [Fact]
+        public void GetStreamTest()
+        {
+            int testColOrdinal = 1;
+            byte[] buffer = new byte[1024];
+
+            _dataReader.Read();
+            Stream stream = _dataReader.GetStream(testColOrdinal);
+            Assert.NotNull(stream);
+
+            // Read stream content to byte buffer
+            int data_length = stream.Read(buffer, 0, buffer.Length);
+
+            // Verify that content is expected
+            byte[] expected = new byte[] { 0xDE, 0xAD, 0xBE, 0xEF };
+            Assert.Equal(expected.Length, data_length);
+            for (int i = 0; i < expected.Length; i++)
+            {
+                Assert.Equal(expected[i], buffer[i]);
+            }
+
+            // Get DBNull value stream
+            Assert.True(_dataReader.Read());
+            stream = _dataReader.GetStream(testColOrdinal);
+            Assert.Equal(0, stream.Length);
+
+            // Get single byte value stream
+            Assert.True(_dataReader.Read());
+            stream = _dataReader.GetStream(testColOrdinal);
+            expected = new byte[] { 0x00 };
+            Assert.Equal(expected.Length, stream.Length);
+            Assert.Equal(expected[0], stream.ReadByte());
         }
 
-               [Fact]
-               public void GetFieldValueTest()
-               {
-                       //First row
-                        _dataReader.Read();
-                       Assert.Equal("row_1", _dataReader.GetFieldValue<string>(0));
-                       byte[] expected_data = new byte[] { 0xde, 0xad, 0xbe, 0xef };
-                       byte[] actual_data = _dataReader.GetFieldValue<byte[]>(1);
-                       Assert.Equal(expected_data.Length, actual_data.Length);
-                       for (int i = 0; i < expected_data.Length; i++)
-                       {
-                               Assert.Equal(expected_data [i], actual_data [i]);
-                       }
-
-                       //Second row where data row column value is DBNull
-                        _dataReader.Read();
-                       Assert.Equal("row_2", _dataReader.GetFieldValue<string>(0));
-                       Assert.Throws<InvalidCastException>(() => _dataReader.GetFieldValue<byte[]>(1));
-
-                       //Third row
-                        _dataReader.Read();
-                       Assert.Equal("row_3", _dataReader.GetFieldValue<string>(0));
-                       expected_data = new byte[] { 0x00 };
-                       actual_data = _dataReader.GetFieldValue<byte[]>(1);
-                       Assert.Equal(expected_data.Length, actual_data.Length);
-                       Assert.Equal(expected_data [0], actual_data [0]);
-               }
-
-               [Fact]
-               public void GetStreamTest()
-               {
-                       int testColOrdinal = 1;
-                       byte[] buffer = new byte[1024];
-
-                        _dataReader.Read();
-                       Stream stream = _dataReader.GetStream(testColOrdinal);
-                       Assert.NotNull(stream);
-
-                       //Read stream content to byte buffer
-                       int data_length = stream.Read(buffer, 0, buffer.Length);
-
-                       //Verify that content is expected
-                       byte[] expected = new byte[] { 0xde, 0xad, 0xbe, 0xef };
-                       Assert.Equal(expected.Length, data_length);
-                       for (int i = 0; i < expected.Length; i++)
-                       {
-                               Assert.Equal(expected [i], buffer [i]);
-                       }
-
-                       //Get DBNull value stream
-                       Assert.True(_dataReader.Read());
-                       stream = _dataReader.GetStream(testColOrdinal);
-                       Assert.Equal(0, stream.Length);
-
-                       //Get single byte value stream
-                       Assert.True(_dataReader.Read());
-                       stream = _dataReader.GetStream(testColOrdinal);
-                       expected = new byte[] { 0x00 };
-                       Assert.Equal(expected.Length, stream.Length);
-                       Assert.Equal(expected [0], stream.ReadByte());
-               }
-
-               [Fact]
-               public void GetTextReader()
-               {
-                       int testColOrdinal = 0;
-
-                       //Read first row
-                        _dataReader.Read();
-                       TextReader textReader = _dataReader.GetTextReader(testColOrdinal);
-                       Assert.NotNull(textReader);
-
-                       string txt = textReader.ReadToEnd();
-                       Assert.Equal("row_1", txt);
-
-                       //Move to second row
-                       Assert.True(_dataReader.Read());
-                       textReader = _dataReader.GetTextReader(testColOrdinal);
-                       txt = textReader.ReadToEnd();
-                       Assert.Equal("row_2", txt);
-
-                       //Move to third row
-                       Assert.True(_dataReader.Read());
-                       textReader = _dataReader.GetTextReader(testColOrdinal);
-                       txt = textReader.ReadToEnd();
-                       Assert.Equal("row_3", txt);
-
-                       Assert.False(_dataReader.Read());
-               }
+        [Fact]
+        public void GetTextReader()
+        {
+            int testColOrdinal = 0;
+
+            // Read first row
+            _dataReader.Read();
+            TextReader textReader = _dataReader.GetTextReader(testColOrdinal);
+            Assert.NotNull(textReader);
+
+            string txt = textReader.ReadToEnd();
+            Assert.Equal("row_1", txt);
+
+            // Move to second row
+            Assert.True(_dataReader.Read());
+            textReader = _dataReader.GetTextReader(testColOrdinal);
+            txt = textReader.ReadToEnd();
+            Assert.Equal("row_2", txt);
+
+            // Move to third row
+            Assert.True(_dataReader.Read());
+            textReader = _dataReader.GetTextReader(testColOrdinal);
+            txt = textReader.ReadToEnd();
+            Assert.Equal("row_3", txt);
+
+            // Move to fourth row
+            Assert.True(_dataReader.Read());
+            textReader = _dataReader.GetTextReader(testColOrdinal);
+            txt = textReader.ReadToEnd();
+            Assert.Equal(".NET", txt);
+
+            Assert.False(_dataReader.Read());
+        }
     }
 }
-
diff --git a/src/libraries/System.Data.Common/tests/System/Data/Common/DbDataReaderTest.netcoreapp.cs b/src/libraries/System.Data.Common/tests/System/Data/Common/DbDataReaderTest.netcoreapp.cs
new file mode 100644 (file)
index 0000000..c81219d
--- /dev/null
@@ -0,0 +1,328 @@
+using Xunit;
+
+namespace System.Data.Tests.Common
+{
+    public partial class DbDataReaderTest
+    {
+        [Fact]
+        public void GetBooleanByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = true;
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var actual = _dataReader.GetBoolean("boolean_col");
+
+            Assert.Equal(expected, actual);
+        }
+
+        [Fact]
+        public void GetByteByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = (byte)0x00;
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var actual = _dataReader.GetByte("byte_col");
+
+            Assert.Equal(expected, actual);
+        }
+
+        [Fact]
+        public void GetBytesByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = new byte[] { 0xAD, 0xBE };
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var actual = new byte[1024];
+            var length = _dataReader.GetBytes("binary_col", 1, actual, 0, 2);
+
+            Assert.Equal(expected.Length, length);
+            for (int i = 0; i < expected.Length; i++)
+            {
+                Assert.Equal(expected[i], actual[i]);
+            }
+        }
+
+        [Fact]
+        public void GetCharByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = 'E';
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var actual = _dataReader.GetChar("char_col");
+
+            Assert.Equal(expected, actual);
+        }
+
+        [Fact]
+        public void GetCharsByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = new char[] { 'N', 'E', 'T' };
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            const int dataLength = 1024;
+
+            var actual = new char[dataLength];
+            var length = _dataReader.GetChars("text_col", 1, actual, 0, dataLength);
+
+            Assert.Equal(expected.Length, length);
+            for (int i = 0; i < expected.Length; i++)
+            {
+                Assert.Equal(expected[i], actual[i]);
+            }
+        }
+
+        [Fact]
+        public void GetDateTimeByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = new DateTime(2016, 6, 27);
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var actual = _dataReader.GetDateTime("datetime_col");
+
+            Assert.Equal(expected, actual);
+        }
+
+        [Fact]
+        public void GetDecimalByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = 810.72m;
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var actual = _dataReader.GetDecimal("decimal_col");
+
+            Assert.Equal(expected, actual);
+        }
+
+        [Fact]
+        public void GetDoubleByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = Math.PI;
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var actual = _dataReader.GetDouble("double_col");
+
+            Assert.Equal(expected, actual);
+        }
+
+        [Fact]
+        public void GetFieldValueByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = new byte[] { 0xDE, 0xAD, 0xBE, 0xEF };
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var actual = _dataReader.GetFieldValue<byte[]>("binary_col");
+
+            Assert.Equal(expected.Length, actual.Length);
+            for (int i = 0; i < expected.Length; i++)
+            {
+                Assert.Equal(expected[i], actual[i]);
+            }
+        }
+
+        [Fact]
+        public void GetFloatByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = 776.90f;
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var actual = _dataReader.GetFloat("float_col");
+
+            Assert.Equal(expected, actual);
+        }
+
+        [Fact]
+        public void GetGuidByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = Guid.Parse("893e4fe8-299a-465a-a600-3cd4ad91629a");
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var actual = _dataReader.GetGuid("guid_col");
+
+            Assert.Equal(expected, actual);
+        }
+
+        [Fact]
+        public void GetInt16ByColumnNameTest()
+        {
+            SkipRows(3);
+
+            short expected = 12345;
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var actual = _dataReader.GetInt16("short_col");
+
+            Assert.Equal(expected, actual);
+        }
+
+        [Fact]
+        public void GetInt32ByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = 1234567890;
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var actual = _dataReader.GetInt32("int_col");
+
+            Assert.Equal(expected, actual);
+        }
+
+        [Fact]
+        public void GetInt64ByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = 1234567890123456789;
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var actual = _dataReader.GetInt64("long_col");
+
+            Assert.Equal(expected, actual);
+        }
+
+        [Fact]
+        public void GetStreamByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = new byte[] { 0xDE, 0xAD, 0xBE, 0xEF };
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var stream = _dataReader.GetStream("binary_col");
+            Assert.NotNull(stream);
+
+            var actual = new byte[1024];
+            var readLength = stream.Read(actual, 0, actual.Length);
+
+            Assert.Equal(expected.Length, readLength);
+            for (int i = 0; i < expected.Length; i++)
+            {
+                Assert.Equal(expected[i], actual[i]);
+            }
+        }
+
+        [Fact]
+        public void GetStringByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = ".NET";
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var actual = _dataReader.GetString("text_col");
+
+            Assert.Equal(expected, actual);
+        }
+
+
+        [Fact]
+        public void GetTextReaderByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = ".NET";
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var textReader = _dataReader.GetTextReader("text_col");
+            Assert.NotNull(textReader);
+
+            var actual = textReader.ReadToEnd();
+
+            Assert.Equal(expected, actual);
+        }
+
+        [Fact]
+        public void GetValueByColumnNameTest()
+        {
+            SkipRows(3);
+
+            var expected = ".NET";
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            var actual = _dataReader.GetValue("text_col") as string;
+
+            Assert.NotNull(actual);
+            Assert.Equal(expected, actual);
+        }
+
+        [Fact]
+        public void IsDBNullByColumnNameTest()
+        {
+            SkipRows(3);
+
+            // The row after rowsToSkip
+            _dataReader.Read();
+
+            Assert.False(_dataReader.IsDBNull("text_col"));
+            Assert.True(_dataReader.IsDBNull("dbnull_col"));
+        }
+
+        private void SkipRows(int rowsToSkip)
+        {
+            var i = 0;
+
+            do
+            {
+                _dataReader.Read();
+            } while (++i < rowsToSkip);
+        }
+    }
+}