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.
94<br />
<strong>Enterprise</strong> <strong>Library</strong> <strong>Test</strong> <strong>Guide</strong><br />
Code test case Implemented? Feature that is implemented<br />
Verify that the application<br />
block exposes<br />
a dictionary<br />
collection property<br />
so that the application<br />
block can log<br />
customized logging<br />
information.<br />
Yes<br />
Verify that the<br />
logging application<br />
block can log the<br />
same message to<br />
multiple categories.<br />
Verify that the<br />
application block<br />
logs messages to<br />
the trace listeners<br />
in a thread safe<br />
manner.<br />
Verify that the performance<br />
counters<br />
and the event log<br />
that are required<br />
by the application<br />
block are installed<br />
during installation.<br />
Yes<br />
Yes<br />
Yes<br />
The LogEntry.ExtendedProperties property is a dictionary<br />
collection that supports customized logging information.<br />
This is shown in the following code example.<br />
private IDictionary extended-<br />
Properties;<br />
public IDictionary Extended-<br />
Properties<br />
{<br />
get<br />
{<br />
if (extendedProperties == null)<br />
{<br />
extendedProperties = new Dictionary();<br />
}<br />
return this.extendedProperties;<br />
}<br />
set { this.extendedProperties = value; }<br />
}<br />
The LogEntry class has a categories collection that allows<br />
the application block to log a message to multiple<br />
categories. This is shown in the following code example.<br />
private ICollection categories<br />
The LogSource class verifies that the trace listeners are<br />
thread safe before it logs the information. This is shown<br />
in the following code example.<br />
public void TraceData(…)<br />
{<br />
try<br />
{<br />
if (!listener.IsThreadSafe)<br />
Monitor.Enter(listener);<br />
listener.TraceData(…);<br />
}<br />
finally<br />
{<br />
if (!listener.IsThreadSafe)<br />
Monitor.Exit(listener);<br />
}<br />
}<br />
For example, the LoggingInstrumentationListener class<br />
contains the installer attribute type [HasInstallableResourcesAttribute].<br />
The EventLogInstallerBuilder and PerformanceCounterInstallerBuilder<br />
installer classes, which are part of<br />
the <strong>Enterprise</strong> <strong>Library</strong> Core, recognize this attribute and<br />
install the performance counters and event logs.