Hello:
I would like to test an NHibernate custom type without setting up a db
and a session if I can. To test the NullSafeGet method, I need an
IDataReader with values. My last attempt to do that (below), I'm
trying to use Expect.Do(). I'm not sure if that's a good way to do
this though, or where to trigger something to make it work.
Cheers,
Berryl
[Test]
public void NullSafeGet()
{
var t = new TimePeriodUserType();
var expected = DateRange.AllDay();
var names = new[] {"START", "END"};
///////////////
var rs = MockRepository.GenerateStub<IDataReader>();
rs.Stub(x => x.GetValues(null)).IgnoreArguments().Do(new
Func<object[], int>(_testData));
/////////////
var session =
MockRepository.GenerateStub<ISessionImplementor>();
var owner = MockRepository.GenerateStub<object>();
Assert.That(t.NullSafeGet(rs, names, session, owner),
Is.EqualTo(expected));
}
private static int _testData(object[] fields)
{
var range = DateRange.AllDay();
fields[0] = range.Start.ToString();
fields[1] = range.End.ToString();
return 2;
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/RhinoMocks?hl=en
-~----------~----~----~----~------~----~------~--~---