Something like:
new PersistenceSpecification<Component>(session, new
ComponentEqualityComparer())
public class ComponentEqualityComparer : IEqualityComparer
{
#region IEqualityComparer Members
public bool Equals(object x, object y)
{
if (x == null || y == null)
{
return false;
}
if (x is DateTime && y is DateTime)
{
return true;
}
if (x is ComponentInstance && y is ComponentInstance)
{
return ((ComponentInstance)x).SubscriptionId ==
((ComponentInstance)y).SubscriptionId;
}
return x.Equals(y);
}
public int GetHashCode(object obj)
{
throw new NotImplementedException();
}
#endregion
}
On Mon, Oct 12, 2009 at 9:00 PM, Mikael Henriksson <[email protected]>wrote:
> You need to override equals. Take a look at the aiki.
>
> On Oct 12, 2009 6:38 PM, "Jonty" <[email protected]> wrote:
>
>
> I have an Address mapped as a component on a Customer class and I want
> to test the Customer mapping.
>
> How should I do this? This doesn't work:
>
> new PersistenceSpecification<Customer>(session)
> .CheckProperty(x => x.Address, new Address {
> Address1 = "Blah",
> Address2 = "Blah",
> new Country { Id = 1, Title = "Test" }
> });
>
> (System.ApplicationException: Expected 'Domain.Customer.Address' but
> got 'Domain.Customer.Address' for Property 'Address')
>
> Nor does this:
>
> new PersistenceSpecification<Customer>(session)
> .CheckProperty(x => x.Address.Address1, "Blah")
> .CheckProperty(x => x.Address.Address2, "Blah")
> .CheckProperty(x => x.Address.Country.Id, 1)
> .CheckProperty(x => x.Address.Country.Title, "Blah");
>
> (System.Reflection.TargetException: Object does not match target
> type.)
>
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Fluent NHibernate" 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/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---