The unit of validation in nspectre is a specification. Specifications are based on the Specification Pattern described by Eric Evans and Martin Fowler. nspectre defines an ISpecification class that all specifications must implement. The ISpecification defines one method - IsSatisifedBy - that takes an object to be tested and returns a SpecificationResult, which indicates if the test passed or failed in addition to any errors that occurred. ISpecification also defines a property - Context - that allows values to be passed to a specification.
nspectre defines 6 kinds of specification:
SimpleSpecification - based on a template.
SimpleFunctionSpecification - based on a predefined function. Such a function must return IFunctionResult.
AntiSpecification - returns the opposite of a given specification.
CompositeSpecification - provides a means to group specifications together into one specification. Composite specifcations can be joined with and or or logic and can be shortcircuited.
ExternalSpecification - a specification defined outside nspectre (i.e. a hardcoded specification.) Note that this may require an assembly reference in the configuration.
CustomSpecification - a specification that uses a preprocessor to generate one of the other types of specifications. A preprocessor is a class that implements IPreprocessor. nSpectre has a built in preprocessor (ValidateBase) that provides for validation of base objects from derived objects.