Using Fluent NHibernate persistence testing
Mappings are a critical part of any NHibernate application. In this recipe, we'll show you how to use Fluent NHibernate's persistence testing, in order to make sure that your mappings work as expected. You don't have to use Fluent NHibernate mappings in order to take advantage of this recipe.
Getting ready
Complete the Fast testing with the SQLite in-Memory database recipe mentioned earlier in this chapter.
How to do it...
Install
FluentNHibernate
using the NuGet Package Manager Console by executing the following command:Install-Package FluentNHibernate
In
PersistenceTests.cs
, add the followingusing
statement:using FluentNHibernate.Testing;
Add the following three tests to the
PersistenceTests
fixture:[Test] public void Product_persistence_test() { new PersistenceSpecification<Product>(Session) .CheckProperty(p => p.Name, "Product Name") .CheckProperty(p => p.Description, "Product Description") .CheckProperty(p => p.UnitPrice...