I found some time this weekend and created
ExtensibleRandomValuePropertyNamer. I have attached a pathc to an issue
here:
http://code.google.com/p/nbuilder/issues/detail?id=24
A few things I will point out:
1) Notice the patch contains unit tests.
2) This could certainly coexist with the existing RandomValuePropertyNamer.
However, that might be confusing to users. It could instead be a
replacement. However that is a big breaking change. I'm not sure how many
users NBuilder has yet.
3) You will notice that I added a class GetRandom, with a whole bunch of
static helper methods that wrap the random generator. I have been copying
this class from project to project for a while, and I think it would have a
nice home in NBuilder. I retrofitted it to use your random generator and
extended it to handle all of the needs of the namer class.
4) You will notice that I use GetRandom to create the default handlers in
ExtensibleRandomValuePropertyNamer. I considered whether it would be better
to inject the random generator (as the current random namer does), rather
than depend on all these static methods. However, is there really any
reason to ever swap out the implementation of the random generator,
especially now that the user has full control of how every type of member is
handled? Of course c-tor injection would make unit testing a bit more fine
grained, but is that worth the extra effort?
5) I did not spend much time thinking about whether or not we could extract
a supertype from ExtensibleRandomValuePropertyNamer that could be used to
redo SequentialPropertyNamer. Personally, I would not use the sequential
namer. However, it might be possible.
Okay, let me know what you think!
Tim Scott