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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

88<br />

<strong>Enterprise</strong> <strong>Library</strong> <strong>Test</strong> <strong>Guide</strong><br />

Design test case Implemented? Feature that implements design<br />

Verify that the design addresses<br />

situations that can<br />

cause exceptions and that<br />

the application block logs the<br />

exceptions through the instrumentation.<br />

Yes<br />

For example, the LogWriter class includes<br />

the InstrumentationProvider property. This<br />

property retrieves the instrumentation provider<br />

that defines the events for the application<br />

block. It logs the events to WMI and to<br />

the event log.<br />

Verify that the instrumentation<br />

is implemented with loosely<br />

coupled events.<br />

Verify that the application<br />

block can use .NET trace<br />

listeners.<br />

Verify that the application<br />

block supports custom property<br />

collections for the custom<br />

trace listeners, custom formatters,<br />

and custom filters.<br />

Yes<br />

Yes<br />

Yes<br />

The methods in the LoggingInstrumentation-<br />

Provider class that raise the events bind to<br />

the methods in the LoggingInstrumentation-<br />

Listener class at run time.<br />

The SystemDiagnosticsTraceListenerData<br />

class configures .NET trace listeners so that<br />

the application block can use them.<br />

The CustomTraceListenerData class supports<br />

custom property collections for custom<br />

trace listeners. Similarly, the CustomFilter-<br />

Data class and the CustomFormatterData<br />

class support custom property collections for<br />

custom filters and custom formatters.<br />

After the code is implemented, you can review it to see if it satisfies its test cases.<br />

Table 4 lists the results of a code review for the Logging Application Block.<br />

Table 4: Logging Application Block Code Verification<br />

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

Verify that the<br />

Logger façade<br />

exposes all public<br />

members as static<br />

and that it uses<br />

overloads to support<br />

Yes<br />

The Logger.Write method has multiple overloads to log<br />

messages that have different properties. Some of the<br />

overloads are shown in the following code examples.<br />

// writes a message to the category specified<br />

// in the log object<br />

public static void Write(LogEntry log){}<br />

different ways<br />

// writes a log entry to the default category<br />

public static void Write(object message){}<br />

to log information.<br />

// writes a log message to a specific category<br />

public static void Write(object message, string<br />

category){}<br />

// writes a log message to a specific category<br />

// and assigns a priority to the message<br />

public static void Write(object message, string<br />

category, int priority){}

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

Saved successfully!

Ooh no, something went wrong!