i didn't provide a test but i can.  The test i assume would pass would
be (using fluent nh for mapping):

        /// <summary>
        /// Test CellTestPerSpec
        /// </summary>
        [Test]
        public void CellTestPerSpec()
        {
            using(var container = this.GetContainer())
            {
 
container.Value.Register(Component.For<ICellSerial>().ImplementedBy<CellSerial>().LifeStyle.Transient);
                using (var ses = OpenCleanSession())
                {
                    var cellSerial = new CellSerial("G23-123");
                    new PersistenceSpecification<ICell>(ses)
                        .CheckProperty(x => x.Serial, cellSerial)
                        .CheckProperty(x => x.Id, 1)
                        .CheckProperty(x => x.Version, 1)
                        .VerifyTheMappings(new Cell());
                }
            }
        }

where cell is mapped as
    [UsedImplicitly]
    public class CellMap
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="CellMap"/>
class.
        /// </summary>
        public CellMap()
        {
            this.Id(x =>
x.Id).Column("Id").GeneratedBy.Native().UnsavedValue(-1).Not.Nullable();
            this.Version(x =>
x.Version).Column("Version").UnsavedValue("-1").Generated.Never();
            this.Proxy<ICell>();
            this.EntityName(typeof(Interface).ToString());
            Component(x => x.Serial, x =>
                                     {
                                         x.Map(y =>
y.ProductionNumber);
                                         x.Map(y => y.ProductionWeek);
                                         x.Map(y => y.ProductionYear);
                                     });
        }
    }
and cell is
public class Cell
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Cell"/>
class.
        /// </summary>
        /// <param name="validatorEngine">The validation engine.</
param>
        public Cell()
        {

        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Cell"/>
class.
        /// </summary>
        public Cell()
        {

        }

        /// <summary>
        /// Indicates whether the current object is equal to another
object of the same type.
        /// </summary>
        /// <param name="other">An object to compare with this
object.</param>
        /// <returns>
        /// <see langword="true"/> if the current object is equal to
the <paramref name="other"/> parameter; otherwise, <see
langword="false"/>.
        /// </returns>
        public override bool Equals(ICell other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }
            if (ReferenceEquals(this, other))
            {
                return true;
            }
            return this.Serial.Equals(other.Serial);
        }

        /// <summary>
        /// Entity implementation of ToString.
        /// </summary>
        /// <returns>String representation of entity</returns>
        protected override string ToStringImpl()
        {
            return String.Format("Cell Serial: {0}", Serial == null ?
"-" : Serial.ToString());
        }

        /// <summary>
        /// Serial number of this cell.
        /// </summary>
        /// <value></value>
        public ICellSerial Serial { get; set; }
    }

note this will not work as is, i'm not quite sure how i'd repeat this
without creating a ton of misc. code.  If required i could whip
something up but i'm not even really sure this is a bug, if it is in
fact not the desired behavior i can make a proper test.  This is my
current local test to prove out my DAL.

Thanks!

On Mar 9, 5:55 pm, Fabio Maulo <[email protected]> wrote:
> which is the test ?
>
> 2010/3/9 TU <[email protected]>
>
>
>
> > The below function throws an exception (in my case when it tries to
> > instantiate a component interface), if the mappedClass is an
> > interface, shouldn't it goto the second/third elseif part and use
> > either the optomized creator or the bytecode provider to look up the
> > type?  (This way you could have the interface type in your IoC/DI
> > setup and it would create it etc).  Or am i just misunderstanding
> > something?  This works for everything else (i have interfaces
> > everywhere instead of concrete classes and use DI to set them up for
> > nhibernate) but for my component i get this exception.  Is this a bug
> > or to be expected?  Also if it is to be expected, why?  Can this be
> > fixed? (Reorder the if so that if it dosn't find it in the IoC then it
> > throws the exception maybe?) If not is there a work around or am i
> > doing things totally wrong?  Thank you!
> > public object Instantiate()
> >                {
> >                        if (ReflectHelper.IsAbstractClass(mappedClass))
> >                        {
> >                                throw new InstantiationException("Cannot
> > instantiate abstract
> > class or interface: ", mappedClass);
> >                        }
> >                        else if (optimizer != null)
> >                        {
> >                                return optimizer.CreateInstance();
> >                        }
> >                        else if (mappedClass.IsValueType)
> >                        {
> >                                return
> > Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance(mappedClass,
> > true);
> >                        }
> >                        else if (constructor == null)
> >                        {
> >                                throw new InstantiationException("No default
> > constructor for
> > entity: ", mappedClass);
> >                        }
> >                        else
> >                        {
> >                                try
> >                                {
> >                                        return constructor.Invoke(null);
> >                                }
> >                                catch (Exception e)
> >                                {
> >                                        throw new
> > InstantiationException("Could not instantiate entity:
> > ", e, mappedClass);
> >                                }
> >                        }
> >                }
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<nhusers%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.
>
> --
> Fabio Maulo

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to