Disclaimer! Ayende rightly points out that if you are testing your queries you get this mapping test for free. If you aren't, well put this in place as a stop gap measure (to test mappings) and if you have queries, which you probably do, get to testin'!
A while back Bil Simser put up a post on the first test you should write when using Castle Windsor. In it he shows a technique for verifying his component registrations are correct.
Since Windsor and NHibernate are the peanut butter and jelly of the ALT.NET crowd, I think we can and should do the same for NHibernate:
[Test]
public void Verify_NHibernate_mappings()
{
string myConfigPath = @"wherever\you\put\your\NHibernate\config.xml";
Configuration config = new Configuration();
_sessionFactory = config.Configure(nhibernateConfig).BuildSessionFactory();
}
Would that I did this before today. Yeah, I win the douchey team member award for making a bunch of refactorings (renames mostly) and not fixing the mappings. Remember: Resharper, as great as it is, doesn't do NHibernate mappings. Of course the unit tests passed so I think I'm fine and move on with my life. The next developer that updates with my commit can't run the app and gets to clean up my mess. Fun for them!
I've learned my lesson. This little screw up illustrates the need for at least some automated integration tests and the lynchpins of many of our architectures -- the ORM/IoC tools -- seem like easy and high value targets.