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.

202<br />

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

Creating the <strong>Test</strong> Code<br />

The test code implements the scenarios. There are two versions of the test code. The<br />

<strong>Enterprise</strong> <strong>Library</strong> uses one version and the .NET Framework uses the other version.<br />

Only the first scenario is used in the baseline measurements.<br />

Table 16 lists the Exception Handling Application Block test code. The code is the<br />

same for all the scenarios. Only the exception policies vary from one scenario to<br />

another.<br />

Table 16: Exception Handling Application Block <strong>Test</strong> Code<br />

ID Scenario <strong>Test</strong> code<br />

1 Process an exception with<br />

the Wrap handler.<br />

protected void ButtonException_Click(object sender,<br />

EventArgs e)<br />

{<br />

try<br />

{<br />

Exception originalException = new System.FormatExc<br />

eption("Original Exception: format exception");<br />

bool rethrow<br />

=ExceptionPolicy.HandleException(originalEx<br />

ception,<br />

"WrapThrowNewDifferentAssembly");<br />

if (rethrow) throw originalException;<br />

}<br />

catch (Exception ex){ }<br />

}<br />

Table 17 lists the .NET Framework test code.<br />

Table 17: .NET Framework <strong>Test</strong> Code<br />

ID Scenario <strong>Test</strong> code<br />

1 Throw a wrapped<br />

exception.<br />

protected void ExceptionHandling_Click(object sender,<br />

EventArgs e)<br />

{<br />

try<br />

{<br />

Exception originalException = new<br />

System.FormatException("Original Exception:<br />

format<br />

exception");<br />

throw (new System.FormatException("originalEx<br />

ception",<br />

originalException));<br />

}<br />

catch {}<br />

}

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

Saved successfully!

Ooh no, something went wrong!