In a test method (for a Fluent NHibernate mapping, although that's not really relevant) I have the following code wrapped in a bunch of usings and try/catch blocks:
new PersistenceSpecification<Entry>(session)
.CheckProperty(e => e.Id, "1")
.VerifyTheMappings();
I would like to refactor this so that I can pass it to a helper method (where I place the using
and try/catch
blocks).
My requirements for this to work as I want it to are
session
needs to be provided by one of the using statementsEntry
should be provided as a generic parameter, so I can test mappings of various objects- It should be possible to replace
.CheckProperty(e => e.Id, "1").VerifyTheMappings()
with anything that's called on aPersistenceSpecification<T>
when defining the argument (in the test method).
Basically, I'd like to do something like this:
var testAction = new PersistenceSpecification<Entry>(session)
.CheckProperty(e => e.Id, "1")
.VerifyTheMappings();
HelpTestMethod(testAction)
but with the above requirements satisified.