Skip to content

Commit

Permalink
added tests that are similar to those used in SqlClient when adding t…
Browse files Browse the repository at this point in the history
…he LegacyRowVersionNullBehavior functionality
  • Loading branch information
andygjp committed Jul 20, 2021
1 parent 8a93ea3 commit f282a1f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
37 changes: 37 additions & 0 deletions NullRowVersionIssue/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,43 @@ public async Task Customer_without_default_address_uses_first_address_using_data
Assert.Null(ex);
}

[Fact]
public void GetValues_null_rowversion_returns_empty_byte_array()
{
var con = GetConnection();
using var command = con.CreateCommand();
command.CommandText = "select cast(null as rowversion) rv";
using var reader = command.ExecuteReader();
reader.Read();
var data = new object[1];
reader.GetValues(data);
Assert.True(data[0] is byte[] {Length: 0});
}

[Fact]
public void GetValue_null_rowversion_returns_empty_byte_array()
{
var con = GetConnection();
using var command = con.CreateCommand();
command.CommandText = "select cast(null as rowversion) rv";
using var reader = command.ExecuteReader();
reader.Read();
var value = reader.GetValue(0);
Assert.True(value is byte[] {Length: 0});
}

[Fact]
public void GetFieldValue_null_rowversion_does_not_throw_invalid_cast()
{
var con = GetConnection();
using var command = con.CreateCommand();
command.CommandText = "select cast(null as rowversion) rv";
using var reader = command.ExecuteReader();
reader.Read();
var ex = Record.Exception(() => reader.GetFieldValue<byte[]>(0));
Assert.Null(ex);
}

private void AddCustomer(Customer customer)
{
fixture.DataContext.Customers.Add(customer);
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ The test called "Customer_without_default_address_uses_first_address" fails.
The test can be made to pass if the version of Microsoft.Data.SqlClient is downgraded from
version 3.0.0 to 2.1.3 or line 156, `builder.EnableRetryOnFailure();`, is commented out.

The test called "Customer_without_default_address_uses_first_address_using_datareader_GetFieldValue" fails.
The test can be made to pass if the version of Microsoft.Data.SqlClient is downgraded from
version 3.0.0 to 2.1.3

The test called "Customer_without_default_address_uses_first_address_using_datareader_GetValues" fails.
The test can be made to pass if the version of Microsoft.Data.SqlClient is downgraded from
version 3.0.0 to 2.1.3
The following tests fail:
* "Customer_without_default_address_uses_first_address_using_datareader_GetFieldValue"
* "Customer_without_default_address_uses_first_address_using_datareader_GetValues"
* "GetValues_null_rowversion_returns_empty_byte_array"
* "GetValue_null_rowversion_returns_empty_byte_array"
* "GetFieldValue_null_rowversion_does_not_throw_invalid_cast"
They can be made to pass if the version of Microsoft.Data.SqlClient is downgraded from version 3.0.0 to 2.1.3

# Schema generated by EF

Expand Down

0 comments on commit f282a1f

Please sign in to comment.