ADO.NET has the notorious DataRow class which you cannot instantiate using new. This is a problem now that I find a need to mock it using Rhino Mocks.
Does anyone have any ideas how I could get around this problem?
I'm curious as to why you need to mock the DataRow. Sometimes you can get caught up doing mocking and forget that it can be just as prudent to use the real thing. If you are passing around data rows then you can simply instantiate one with a helper method and use that as a return value on your mock.
SetupResult.For(someMockClass.GetDataRow(input)).Return(GetReturnRow());
public DataRow GetReturnRow()
{
DataTable table = new DataTable("FakeTable");
DataRow row = table.NewRow();
row.value1 = "someValue";
row.value2 = 234;
return row;
}
If this is not the situation you are in then I am going to need some example code to be able to figure out what you are trying to do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With