Skip to content

Commit d12c87d

Browse files
committed
Added GetFieldValue test to retrieve Stream
Fixes #144
1 parent 8b0856b commit d12c87d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/AdoNet.Specification.Tests/DataReaderTestBase.cs

+23
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,29 @@ public virtual void GetFieldValue_for_TextReader_throws_for_null_String()
744744
Assert.Throws<InvalidCastException>(() => reader.GetFieldValue<TextReader>(0));
745745
}
746746

747+
[Fact]
748+
public virtual void GetFieldValue_for_Stream()
749+
{
750+
using var connection = CreateOpenConnection();
751+
using var command = connection.CreateCommand();
752+
command.CommandText = Fixture.CreateSelectSql(DbType.Binary, ValueKind.One);
753+
using var reader = command.ExecuteReader();
754+
reader.Read();
755+
using var stream = reader.GetFieldValue<Stream>(0);
756+
Assert.Equal(1, stream.ReadByte());
757+
}
758+
759+
[Fact]
760+
public virtual void GetFieldValue_for_Stream_throws_for_null_Binary()
761+
{
762+
using var connection = CreateOpenConnection();
763+
using var command = connection.CreateCommand();
764+
command.CommandText = Fixture.CreateSelectSql(DbType.Binary, ValueKind.Null);
765+
using var reader = command.ExecuteReader();
766+
reader.Read();
767+
Assert.Throws<InvalidCastException>(() => reader.GetFieldValue<Stream>(0));
768+
}
769+
747770
[Fact]
748771
public virtual void FieldCount_is_zero_after_Delete() => Test_X_after_Delete(x => Assert.Equal(0, x.FieldCount));
749772

0 commit comments

Comments
 (0)