views:

8

answers:

1

Am getting an error on VerifyTheMapping test: System.ApplicationException: For property 'ANonindexedComponent' expected 'Generic.TheDomain.NonindexedComponent' of type 'Generic.TheDomain.NonindexedComponent' but got '' of type 'Generic.TheDomain.NonindexedComponent' and System.ApplicationException: For property 'IndexedComponent' expected 'Generic.TheDomain.IndexedComponent' of type 'Generic.TheDomain.IndexedComponent' but got '' of type 'Generic.TheDomain.IndexedComponent'

given: namespace Generic.TheDomain {

public class UseAIndexedComponent:DomainEntity<UseAIndexedComponent>
{
    public virtual string NameTitle { get; private set; }
    public virtual IndexedComponent IndexedComponent { get; private set; }
}

public class UseANonindexedComponent:DomainEntity<UseANonindexedComponent>
{
    public virtual string TitleName { get; private set; }
    public virtual NonindexedComponent ANonindexedComponent { get; private set; }
}

//we want this one to have a unique index on A B C
public class IndexedComponent
{
    public virtual string A { get; private set; }
    public virtual string B { get; private set; }
    public virtual string C { get; private set; }

    public IndexedComponent(){}
}

//no unique index on this one...
public class NonindexedComponent : IndexedComponent
{
    public NonindexedComponent(){}
}

}

Fluent NHibernate mappings:

using FluentNHibernate.Mapping; using Generic.TheDomain;

namespace Persistence.Mappings { public class IndexedMap : ClassMap { public IndexedMap() { Table("IndexedComponent"); Id(x => x.Id).GeneratedBy.GuidComb(); Map(x => x.NameTitle); Component(x => x.IndexedComponent); } }

public class NonIndexedMap : ClassMap<UseANonindexedComponent>
{
    public NonIndexedMap()
    {
        Table("NonIndexedComponent");
        Id(x => x.Id).GeneratedBy.GuidComb();
        Map(x => x.TitleName);
        Component<NonindexedComponent>(x => x.ANonindexedComponent);
    }
}

public class IndexedComponentMap : ComponentMap<IndexedComponent>
{
    public IndexedComponentMap()
    {
        Map(x => x.A).CustomSqlType("varchar(1)").UniqueKey("ABC");
        Map(x => x.B).CustomSqlType("varchar(1)").UniqueKey("ABC");
        Map(x => x.C).CustomSqlType("varchar(1)").UniqueKey("ABC");
    }
}

public class NonindexedComponentMap : ComponentMap<NonindexedComponent>
{
    public NonindexedComponentMap()
    {
        Map(x => x.A).CustomSqlType("varchar(1)");
        Map(x => x.B).CustomSqlType("varchar(1)");
        Map(x => x.C).CustomSqlType("varchar(1)");
    }
}

}

and the test: [Test] public void VerifyIndexedMapping() { new PersistenceSpecification(Session) .CheckProperty(c => c.NameTitle, "jack") .CheckProperty(x => x.IndexedComponent, new IndexedComponent()) .VerifyTheMappings(); }

    [Test]
    public void VerifyNonIndexedMapping()
    {
        new PersistenceSpecification<UseANonindexedComponent>(Session)
            .CheckProperty(c => c.TitleName, "jill")
            .CheckProperty(x => x.ANonindexedComponent, new NonindexedComponent())
            .VerifyTheMappings();
    }

related questions