I'm writing some Persistence tests but am getting an error that NHibernate can't seem to work with FakeItEasy's fakes. Specifically the error is:
No persister for: Castle.Proxies.FacilityProxy
If I write the test like below it'll work fine and pass
[Test]
public void CanCorrectlyCreateFacilityTable()
{
new PersistenceSpecification<Facility>(session, new DataEqualityComparer())
.CheckProperty(f => f.Id, 1)
.CheckProperty(f => f.Name, _facility.Name)
.CheckReference(f => f.Owner, new Client())
.VerifyTheMappings();
}
However, if I create a fake:
IClient _client;
_client = A.Fake<Client>();
A.CallTo(() => _client.Name).Returns("Preston");
And pass that in to the test instead - it seems to fail with the error above:
[Test]
public void CanCorrectlyCreateFacilityTable()
{
new PersistenceSpecification<Facility>(session, new DataEqualityComparer())
.CheckProperty(f => f.Id, 1)
.CheckProperty(f => f.Name, _facility.Name)
.CheckReference(f => f.Owner, _client)
.VerifyTheMappings();
}
Does anyone know if there's a workaround or possible error on my end?
I've done a bit of research here but can't seem to find this question already asked. Most seem concerned with FakeItEasy's configuration or NHibernate's configuration - which don't seem to be the problem: How do I test extension method of Nhibernate which does not return the value even after specifying return in fakeiteasy? Can I sensibly mock this NHibernate query?