You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've found FastMember to be excellent for wrapping dummy data in unit tests for logic using DbDataReader. It would be great if ObjectReader supported creating a reader with multiple result sets since it is much more user-friendly than DataSet.CreateDataReader.
Current test usage example using NUnit/AutoFixture:
internal sealed class TestRow
{
public string StringColumn { get; set; }
public int? IntColumn { get; set; }
}
[Test, AutoData]
public void Coalesce_ReturnsDefaultNullInt(IFixture fixture, int defaultValue)
{
var row = fixture.Build<TestRow>().Without(r => r.IntColumn).Create();
var sut = ObjectReader.Create(new[] { row });
sut.Read();
var value = sut.Coalesce(nameof(row.IntColumn), defaultValue);
Assert.That(value, Is.EqualTo(defaultValue));
}
This is obviously a very simple example using a single result set, but hopefully you can see how useful it would be to use ObjectReader with AutoFixture to generate more complex data sets without having to resort to mocking or manually building a DataSet.
The text was updated successfully, but these errors were encountered:
I've found FastMember to be excellent for wrapping dummy data in unit tests for logic using
DbDataReader
. It would be great ifObjectReader
supported creating a reader with multiple result sets since it is much more user-friendly thanDataSet.CreateDataReader
.Current test usage example using NUnit/AutoFixture:
This is obviously a very simple example using a single result set, but hopefully you can see how useful it would be to use
ObjectReader
with AutoFixture to generate more complex data sets without having to resort to mocking or manually building aDataSet
.The text was updated successfully, but these errors were encountered: