Is there a workaround to test mapping for classes like this (list exposed as
enumerable)?

public class Category
{
    private readonly IList<Category> children;

    public virtual Guid Id { get; set; }
    public virtual string Name { get; set; }

    public Category()
    {
        children = new List<Category>();
    }

    public virtual IEnumerable<Category> Children
    {
        get { return children; }
    }

    public virtual void AddCategory(Category category)
    {
        children.Add(category);
    }
}

This fails due to this bug I have reported.
http://code.google.com/p/fluent-nhibernate/issues/detail?id=249

public class CategoryMap : ClassMap<Category>
{
  public CategoryMap()
  {
   Id(x => x.Id);
   Map(x => x.Name);
   HasMany(x =>
x.Children).Access.AsReadOnlyPropertyThroughCamelCaseField().Cascade.AllDeleteOrphan();
  }
}

[TestFixture]
public class CategoryMapTest : MappingBaseTester<Category>
{
  [Test]
  public void Can_save_category()
  {
   new PersistenceSpecification<Category>(Session)
    .CheckList(x => x.Children, new List<Category> {new Category {Name =
"Sub1"}, new Category {Name = "Sub2"}})
    .VerifyTheMappings();
  }
}

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to