07.11.2014 Views

Enterprise Library Test Guide - Willy .Net

Enterprise Library Test Guide - Willy .Net

Enterprise Library Test Guide - Willy .Net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Test</strong>ing the Logging Application Block 91<br />

Code test case Implemented? Feature that is implemented<br />

Verify that all<br />

logged messages<br />

are also logged to<br />

the all events special<br />

trace source, if<br />

it is in the configuration<br />

source.<br />

Yes<br />

The LogWriter.DoGetMatchingTraceSources method<br />

adds the AllEventsTraceSource object to to the matching<br />

trace sources for every request. This is shown in the<br />

following code example.<br />

private IEnumerable DoGetMatchingTra<br />

ceSources(LogEntry logEntry)<br />

{<br />

…<br />

matchingTraceSources.Add(structureHolder.AllEventsTraceSource);<br />

…<br />

}<br />

Verify that an<br />

assembler class<br />

that implements<br />

the IAssembler<br />

interface injects<br />

the configuration<br />

values into the<br />

domain objects.<br />

Verify that the<br />

application block<br />

can trace an activity<br />

from start to<br />

finish.<br />

Yes<br />

Yes<br />

For example, the PriorityFilterAssembler class creates<br />

the PriorityFilter domain objects. The TextFormatterAssembler<br />

class creates the TextFormatter domain objects<br />

and the FormattedEventLogListenerAssembler class<br />

creates the FormattedEventLogListener domain objects.<br />

All these classes implement the IAssembler interface.<br />

The Tracer class traces an activity from start to finish.<br />

The trace is initialized when the application block creates<br />

a Tracer object in the Tracer class constructor. Tracing<br />

stops when the Dispose method of the Tracer object is<br />

invoked. This is shown in the following code example.<br />

public Tracer(string operation)<br />

{<br />

…<br />

Initialize(operation,…);<br />

}<br />

protected virtual void Dispose(bool disposing)<br />

{<br />

…<br />

if (IsTracingEnabled()) WriteTraceEndMessage(e<br />

ndTitle);<br />

…<br />

}<br />

continued

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!