-
Notifications
You must be signed in to change notification settings - Fork 1
C# Object to Object Literal Constructor for NHibernate Unit Testing
The code in this repository is a proof of concept for taking a C# NHibernate Object graph in memory and creating a C# 3.0 Object Literal Constructor that can be pasted into any unit test framework. This is not yet a general case solution, but does create working C# Object Literal constructed objects on my real world data.
There is no dependency on NHibernate, except that it assumes that every entity has been freshly loaded from by NHibernate, and thus has a Key property which can be used to compare two entities.
In order to support parent references, such as each Line Item on an Order having a reference to the order, this code maintains a list of each entity it encounters, and when subsequent references are found, emits the location of the variable or property where the Entity was originally declared.
Feel free to request additional features and/or take this code and modify it in any way you see fit.
Jeff Lomax