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.
160<br />
<strong>Enterprise</strong> <strong>Library</strong> <strong>Test</strong> <strong>Guide</strong><br />
A tool that may help you prepare your code for globalization testing is Strgen. Strgen<br />
is a multilingual text generator tool that generates multi-lingual strings. The tool can<br />
be downloaded from Multilingual Text Generator – STRGEN on Microsoft.com.<br />
Note: Strgen is distributed “as-is,” with no obligations or technical support from Microsoft<br />
Corporation.<br />
Creating a <strong>Test</strong> Plan<br />
The test plan is made up of the test cases that determine whether the application<br />
blocks adhere to globalization best practices. Table 1 lists the test cases for the<br />
<strong>Enterprise</strong> <strong>Library</strong> application blocks.<br />
Table 1: <strong>Test</strong> Plan for <strong>Enterprise</strong> <strong>Library</strong> Application Blocks<br />
<strong>Test</strong> case<br />
Verify that the application block converts<br />
strings to Unicode characters<br />
from the managed format (Unicode)<br />
used within the application blocks.<br />
Verify that any text that the application<br />
block sends to external<br />
resources, such as a file, a database,<br />
a message queue, and e-mail,<br />
are Unicode characters with UTF-8<br />
encoding.<br />
Verify that application blocks that<br />
use public APIs can accept culture-specific<br />
information such as<br />
addresses, currency, dates, and<br />
numerals. In addition, verify that the<br />
output is displayed in the appropriate,<br />
culture-specific format.<br />
Example<br />
In the following example, the platform uses the .NET<br />
Framework CharSet.Unicode attribute to marshal strings<br />
as Unicode characters.<br />
[DllImport("kernel32.dll", CharSet =CharSet.<br />
Unicode)]<br />
public static extern IntPtr<br />
GetModuleHandle(string moduleName);<br />
In the following example, messages that the application<br />
block sends in e-mail are set to UTF-8 encoding.<br />
MailMessage message = new MailMessage();<br />
message.BodyEncoding = Encoding.UTF8;<br />
In the following example, the application block first converts<br />
a date and time that are in local time to universal<br />
time before processing them. It then converts them back<br />
to local time before displaying them.<br />
// Converts the local time to universal<br />
// time before processing it.<br />
System.DateTime univDateTime = localTime.ToUniversalTime();<br />
// Do the processing using universal time.<br />
// Convert the universal time back to local<br />
// time to display it.<br />
System localTime = univTime.ToLocalTime();