- Posted by zachariahyoung on August 25, 2008
In this post, I would like to outline the contribution I made to the fluent-nhibernate API open source project. One of the features of the API is a fluent interface for creating the nhibernate configuration file for the ISessionFactory. The ISessionFactory provides a few optional configuration properties. An example of one these properties is max_fetch_depth.
The max_fetch_depth property sets a maximum "depth" for the outer join fetch tree for single-ended associations (one-to-one, many-to-one). A 0 disables default outer join fetching.
After reviewing the way some of the other properties had already been set up. I started with creating my first unit test to include this property. Below is the unit test I created.
1: [Test]
2: public void Max_Fetch_Depth_should_set_property_value()
3: {
4: _config.MaxFetchDepth(2);
5: ValueOf("max_fetch_depth").ShouldEqual("2");
6: }
Then I implemented the following code for MaxFetchDepth.
1: public THIS MaxFetchDepth(int maxFetchDepth)
2: {
3: _values.Store(MaxFetchDepthKey, maxFetchDepth.ToString());
4: return (THIS)this;
5: }
This contribution was really easy to code, since I already had some other examples. I was able to include all of the optional configuration properties with unit test.
Hopefully I will be able to add more contributions to the project. As I do I will post to let everyone know.