Enterprise Library Test Guide - Willy .Net
Enterprise Library Test Guide - Willy .Net
Enterprise Library Test Guide - Willy .Net
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
72<br />
<strong>Enterprise</strong> <strong>Library</strong> <strong>Test</strong> <strong>Guide</strong><br />
Code test case<br />
Verify that an assembler<br />
class that implements<br />
the IAssembler interface<br />
creates the exception<br />
handlers and injects the<br />
configuration object values<br />
into those domain objects.<br />
Implemented?<br />
Yes<br />
Feature that is implemented<br />
The following code demonstrates how the Logging-<br />
ExceptionHandlerAssembler class, which implements<br />
the IAssembler interface, creates a LoggingException-<br />
Handler object. The Assemble method in the Logging-<br />
ExceptionHandlerAssembler class injects the configuration<br />
data from the LoggingExceptionHandler object<br />
into the LoggingExceptionHandler domain object. The<br />
process is similar for all the exception handlers that<br />
implement the IExceptionHandler interface.<br />
public class LoggingExceptionHandlerAssembler<br />
: IAssembler<br />
{<br />
public IExceptionHandler<br />
Assemble(IBuilderContext context, Exception-<br />
HandlerData objectConfiguration, IConfigurationSource<br />
configurationSource, ConfigurationReflectionCache<br />
reflectionCache)<br />
{<br />
LoggingExceptionHandlerData castedObjectConfiguration=<br />
(LoggingExceptionHandlerData)objec<br />
tConfiguration;<br />
…<br />
LoggingExceptionHandler createdObject = new<br />
LoggingExceptionHandler(castedObjectConfigur<br />
ation.LogCategory,castedObjectConfiguration.<br />
EventId,castedObjectConfiguration.Severity,ca<br />
stedObjectConfiguration.Title,castedObjectCon<br />
figuration.Priority,castedObjectConfiguration.<br />
FormatterType,writer);<br />
return createdObject;<br />
}<br />
}