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 Data Access Application Block 61<br />

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

Verify that the connection<br />

string property is configurable<br />

and is implemented as<br />

a connection string section<br />

that is supported by the .NET<br />

Framework.<br />

Yes<br />

In the application configuration file, the<br />

connection string is exposed as a <br />

section that is supported by the<br />

.NET Framework. This is shown in the following<br />

XML example.<br />

<br />

<br />

<br />

The GetConnectionStringSettings method<br />

on the DatabaseConfigurationView class<br />

reads the connection string section from the<br />

configuration source. This is shown in the following<br />

code example.<br />

public ConnectionStringSettings GetCo<br />

nnectionStringSettings(string name)<br />

{<br />

…<br />

ConfigurationSection configSection =<br />

configurationSource.GetSection("connec<br />

tionStrings");<br />

if ((configSection != null) && (config-<br />

Section is ConnectionStringsSection))<br />

{<br />

ConnectionStringsSection connection-<br />

StringsSection = configSection as ConnectionStringsSection;<br />

connectionStringSettings = connectionStringsSection.<br />

ConnectionStrings[name];<br />

}<br />

else<br />

connectionStringSettings = ConfigurationManager.ConnectionStrings[name];<br />

…<br />

}<br />

Verify that the application<br />

block can use an instance<br />

name to create a Databasederived<br />

object.<br />

Yes<br />

The DatabaseFactory.Create method has<br />

two overloads. One of the methods accepts<br />

an instance name as a parameter to create<br />

a Database-derived object for the specified<br />

instance name. This is shown in the following<br />

code example.<br />

public static Database<br />

CreateDatabase(string name)<br />

{<br />

}<br />

continued

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

Saved successfully!

Ooh no, something went wrong!