I'm using Fluent NHibernate to map classes to a database and I'm using PersistenceSpecification.VerifyTheMappings() to verify the mappings in my unit tests.
If ClassA has a property of type ClassB and I want to verify the mapping, I first create an instance of ClassB then I try to use it with PersistenceSpecification like this:
ClassB classB = new ClassB();
new PersistenceSpecification<ClassA>(session)
.CheckProperty(x => x.ClassB, classB)
.VerifyTheMappings();
When I run the test in NUnit, the test fails with the following error:
System.ApplicationException : For property 'ClassB' expected 'MyNamespace.ClassB' of type 'MyNamespace.ClassB' but got 'ClassBProxyf24bc4...' of type 'MyNamespace.ClassB'
I also tried using "CheckReference" instead of "CheckProperty", but I got the same results. Creating the ClassB instance inline within CheckProperty() also didn't make a difference - not that I expected it to...
I've come across code examples on the web that imply that this should work. What am I missing here?