Greetings fellow Fluent NHibernate users and developers,

I have recently started using FH and it's been great. When using the
PersistenceSpecification to test my domain model integration I
stumbled upon two tiny buglets/limitations. I forked the source code
on github (http://github.com/ivanz/fluent-nhibernate) and fixed them.
So here I am asking for a review of my patches so that we could get
them upstream if possible.

I have created a branch for each of them so that review can be easier
(I hope). Ideally if you are going to merge them both you should pull
from my master because both commits touch the same file and won't
apply cleanly if you cherry pick from each branch. So here we go:


==> Patch 1: 
http://github.com/ivanz/fluent-nhibernate/commit/37d113dd9a5396e0d536fd780df5b0d66a013013

Branch: http://github.com/ivanz/fluent-nhibernate/commits/bug-54

Description:

Fix bug 54 ( http://code.google.com/p/fluent-nhibernate/issues/detail?id=54
) so that it is now possible to use chained property references when
testing components or one-to-one references. E.g.:

        new PersistenceSpecification<User> (base.Session)
            .CheckProperty (user =>
user.Preferences.DailyCaloriesTarget, 1500)

Without this commit Fluent NHibernate will throw trying to set the
value on "user.DailyCaloriesTarget" instead of
“user.Preferences.DailyCaloriesTarget”.

It is important to note that your POCOs have to internally initialize
the nested objects/components at construction. Otherwise you should be
using CheckReference instead.

The fix involves the following refactoring:

     - Refactor Testing.Values.*Property to wrap a property Accessor
instead of a PropertyInfo directly, because unlike the PropertyInfo
the Accessor infrastructure already handles chained property
references.
     - Refactor PersistenceSpecificationExtensions(...) to call
ReflectionHelper.GetAccessor instead of ReflectionHelper.GetProperty
(...) so that we get an Accessor instead of a PropertyInfo to store.
     - Fixup the unit tests to use Accessor instead of PropertyInfo.



==> Patch 2: 
http://github.com/ivanz/fluent-nhibernate/commit/d6f5b074b583dd648f3daf8f3050a4518ff6ba70

Branch: 
http://github.com/ivanz/fluent-nhibernate/commits/check-property-comparer

Description:

Implement property-level equality comparison specification in addition
to the entity-level one and add tests.

If there is no property-level equality comparer the code will fall-
back to the entity-level comparer and if neither are set simply to
Object.Equals.

An example:

        new PersistenceSpecification<Food> (base.Session, new
EntityLevelEqualityComparer ())
            .CheckProperty (food => food.Image, new Bitmap (20, 20),
new BitmapEqualityComparer ())
            .CheckProperty (food => food.Brand, "banana")
            .VerifyTheMappings ();

Here for the property Image the BitmapEqualityComparer will be used
and for the property Brand the EntityLevelEqualityComparer.


Please review.

Kind Regards,
Ivan Zlatev

--

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.


Reply via email to