Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added GetFieldValue test to retrieve Stream #145

Merged
merged 1 commit into from
Sep 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/AdoNet.Specification.Tests/DataReaderTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,29 @@ public virtual void GetFieldValue_for_TextReader_throws_for_null_String()
Assert.Throws<InvalidCastException>(() => reader.GetFieldValue<TextReader>(0));
}

[Fact]
public virtual void GetFieldValue_for_Stream()
{
using var connection = CreateOpenConnection();
using var command = connection.CreateCommand();
command.CommandText = Fixture.CreateSelectSql(DbType.Binary, ValueKind.One);
using var reader = command.ExecuteReader();
reader.Read();
using var stream = reader.GetFieldValue<Stream>(0);
Assert.Equal(1, stream.ReadByte());
}

[Fact]
public virtual void GetFieldValue_for_Stream_throws_for_null_Binary()
{
using var connection = CreateOpenConnection();
using var command = connection.CreateCommand();
command.CommandText = Fixture.CreateSelectSql(DbType.Binary, ValueKind.Null);
using var reader = command.ExecuteReader();
reader.Read();
Assert.Throws<InvalidCastException>(() => reader.GetFieldValue<Stream>(0));
}

[Fact]
public virtual void FieldCount_is_zero_after_Delete() => Test_X_after_Delete(x => Assert.Equal(0, x.FieldCount));

Expand Down