CheckReference in below test fails due to that
PersistenceSpecification returns a proxy class so "obj.GetType() !=
typeof(Category)" fails in Category.Equals.
I had to add a check if type starts with CategoryProxy which is not nice.
Anyone has a better solution?
[TestFixture]
public class ProductMapTest : MappingBaseTester<Product>
{
[Test]
public void Can_save_product()
{
new PersistenceSpecification<Product>(Session)
.CheckProperty(x => x.Name, "Abc")
.CheckProperty(x => x.SKU, "136-89-010")
.CheckReference(x => x.Category, new Category{Name = "Electronics"})
.VerifyTheMappings();
}
}
public class Category : IIdentity
{
...
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
################ Note the check if type name starts with
CategoryProxy ##################
if (obj.GetType() != typeof(Category) &&
!obj.GetType().Name.StartsWith(typeof(Category).Name + "Proxy"))
return false;
return Equals((Category) obj);
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---