PersistenceSpecification deep object graph testing

18 views
Skip to first unread message

epitka

unread,
Dec 30, 2009, 10:29:12 AM12/30/09
to Fluent NHibernate
I am wondering what strategy others use in regards to testing deep
object graphs. I am especially interested in testing one-to-many with
non-nullable FK with cascade all-delete-orphan, but it applies to
other types as well.

For example if I have following:

A<>--B<>--C<>--D how do you test map for D? Do you have to create
"statefull" test where you persist from root and then fetch when
testing next child in hierarchy. This might be an option since we are
testing mapping only, so maintaining state might be ok. Or do you use
some other strategy?

Hudson Akridge

unread,
Dec 31, 2009, 9:28:38 AM12/31/09
to fluent-n...@googlegroups.com
I honestly don't use the persistence specification for that. At some point, it becomes too cumbersome for me. In that kind of a scenario, I would test it natively. So build a model of A to B to C to D, persist, retrieve, and then assert my assumptions as needed from A to D.

But perhaps others have better ways of doing it.


--

You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group.
To post to this group, send email to fluent-n...@googlegroups.com.
To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.





--
- Hudson
http://www.bestguesstheory.com
http://twitter.com/HudsonAkridge

epitka

unread,
Dec 31, 2009, 10:42:04 AM12/31/09
to Fluent NHibernate
That is what I ended up doing. Just build the model as I go and clean
up at the end.

On Dec 31, 8:28 am, Hudson Akridge <hudson.akri...@gmail.com> wrote:
> I honestly don't use the persistence specification for that. At some point,
> it becomes too cumbersome for me. In that kind of a scenario, I would test
> it natively. So build a model of A to B to C to D, persist, retrieve, and
> then assert my assumptions as needed from A to D.
>
> But perhaps others have better ways of doing it.
>
>
>
>
>
> On Wed, Dec 30, 2009 at 9:29 AM, epitka <exptrade2...@yahoo.com> wrote:
> > I am wondering what strategy others use in regards to testing deep
> > object graphs.  I am especially interested in testing one-to-many with
> > non-nullable FK with cascade all-delete-orphan, but it applies to
> > other types as well.
>
> > For example if I have following:
>
> > A<>--B<>--C<>--D how do you test map for D? Do you have to create
> > "statefull" test where you persist from root and then fetch when
> > testing next child in hierarchy. This might be an option since we are
> > testing mapping only, so maintaining state might be ok. Or do you use
> > some other strategy?
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Fluent NHibernate" group.
> > To post to this group, send email to fluent-n...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr i...@googlegroups.com>

DanielT

unread,
Jan 6, 2010, 2:46:10 AM1/6/10
to Fluent NHibernate
There is one way to do a deep object graph comparison, using
Compare .NET Objects, located here:

http://comparenetobjects.codeplex.com/

The problem is that it does a GetType() equality check so if you use
lazy loading, it'll grab the proxy type instead of the actual object
and return false. The 'fix' is to disable the GetType() check by
modifying the source, which causes it to compare the two graphs
correctly.

Reply all
Reply to author
Forward
0 new messages