I am writing unit tests using Autofixture and FakeItEasy for little tasks that are talking to the database through NHibernate. My test cases also include scenarios where a given object is not found in the database, and therefore I'd like to emulate that the queries return null
.
Now, I managed to achieve this by using the following calls:
var _session = _fixture.Freeze<ISession>();
A.CallTo(_session).WithReturnType<Foo>().Returns(null);
A.CallTo(_session).WithReturnType<Bar>().Returns(null);
// ~10 more of these with just different types defined
but I was wondering if there is a way of setting this up as the default behaviour - so that all calls to _session
with a generic parameter will return null
by default?