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?
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?
Any time I can't mock something (I prefer MoQ over Rhino, but that's beside the point) I have to code around it.
The way I see it you only have two choices. Pay for a superior framework such as TypeMock that can mock ANY class, or code a wrapper around classes that weren't written to be mocked.
Its a sad state of affairs in the framework. TDD wasn't a big concern back in the 1.1 days.
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.
I also use Typemock Isolator for this, it can mock things that other mocking frameworks are unable to.