Enhancement to load SpecExpress ValidationCatalog from configuration file.

Apr 16, 2010 at 1:49 PM

I really like SpecExpress a lot.  I might be given a requirement from the powers that be that the bulk of my validation be put into a configuration file (and hence, possibly stored in a database).

I have written lots of custom configuration sections and would like to know if SpecExpress has any future plans for the validators being loaded from a configuration file.  If not, would you give your blessing to such an endeavor especially if you oversaw the architecture?

I would assume there would be a SpecExpress.Configuration assembly.

Maybe something like:

if (loadFromConfiguration)

{

 

    // The SpecExpress configuration is in a seperate config file.

    var map = new ExeConfigurationFileMap();

    map.ExeConfigFilename = Path.Combine(“somePath”, "SpecExpress.config");

    var config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);

   

    var section = (SpecExpressSection)config.GetSection("SpecExpress");

    section.Configure(ValidationCatalog);

}

else

{

    ValidationCatalog.Scan(x => x.AddAssembly(Assembly.LoadFile(fileName))); }

}

 

Thanks.

Coordinator
Apr 16, 2010 at 2:47 PM

HI Bill,

Thanks for your compliment!

As of this moment, we do not have on the road map any plans to facilitate defining specifications in an XML or Database.  However, if you are interested in developing an extension for this, we would welcome and support your efforts. 

Personally, both Alan and I enjoy the ability to define and run unit tests against our specifications that we write and consider the business rules a core piece of the domains we write.  Extracting these out to an XML or a Database means that the rules could fluctuate or change rapidly external to the domain business logic and makes unit testing a bit more difficult to fully achieve and maintain.  This said, we know that there are many differing perspectives and practices that drive different needs.

Thanks again for your feedback!

Randy

Apr 16, 2010 at 3:32 PM

Randy,

I agree that it makes it more difficult to insure that all the unit test are in place if the business rules can be configured outside of the system.  Since I have come on board, this is the first time they are truly doing TDD and therefore I think that I can talk them out of moving the rules to configuration.

I will let you know otherwise.

Thanks.