Hello, I am a fan of the PersistenceSpecification class. It is a really nice feature that I am able to test properties that are readonly together with an Add method. Here's an example (only relevant parts included):
public class Board { private readonly ISet<Board> successors = new HashedSet<Board>(); public virtual IEnumerable<Board> Successors { get { return successors; } } public virtual void AddSuccessor(Board successor) { successors.Add(successor); } } public class BoardMap : ClassMap<Board> { public BoardMap() { HasManyToMany(x => x.Successors) .Access.ReadOnlyPropertyThroughLowerCaseField() .ParentKeyColumn("ParentId") .ChildKeyColumn("ChildId") .Cascade.All() .AsSet() .Table("Successors"); } } This is the way I like to have things. Successors property is readonly and there's an AddSuccessor method instead. To test this with PersistenceSpecification class I need to specify how to use the AddSuccessor method. Luckily this is possible. Here's how it's done: [Test] public void VerifyBoardMappings() { using (var session = SessionFactory.OpenSession()) { new PersistenceSpecification<Board>(session) .CheckList(b => b.Successors, new HashSet<Board>() { Board.Start.Play(Move.D3) }, (board, successor) => board.AddSuccessor(successor)) .VerifyTheMappings(); } } An explanation: "b => b.Successors" This line identifies which list property we are testing. It should compare same before and after database round-trip. "new HashSet<Board>() { Board.Start.Play(Move.D3) }" This line is an IEnumerable<Board> with values to place in the list property. "(board, successor) => board.AddSuccessor(successor))" This line identifies an action with a custom method of adding values to the list property. That's all there is to it. I can really recommend using the PersistenceSpecification class to verify your mappings. It would also be nice if the wiki page could be updated with examples like the above. Regards, Daniel Lidström -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to fluent-nhibernate@googlegroups.com. To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.