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.
<strong>Test</strong>ing the Security Application Block 105<br />
Design test case Implemented? Feature that implements design<br />
Verify that the<br />
instrumentation<br />
uses loosely coupled<br />
events.<br />
Yes<br />
The methods in the SecurityCacheProviderInstrumentationProvider<br />
class and the AuthorizationProviderInstrumentationProvider<br />
class raise the events<br />
that bind to the methods in the SecurityCacheProviderInstrumentationListener<br />
class and the AuthorizationProviderInstrumentationListener<br />
class<br />
respectively during run time.<br />
Verify that situations<br />
that can cause<br />
exceptions are<br />
addressed and that<br />
the application block<br />
logs the exceptions<br />
through the instrumentation.<br />
Verify that the<br />
application block<br />
supports custom<br />
property collections<br />
for custom security<br />
cache providers and<br />
for custom authorization<br />
providers.<br />
Yes<br />
Yes<br />
For example, both the CachingStoreProvider class<br />
and the AuthorizationRuleProvider class include<br />
the InstrumentationProvider property. This property<br />
retrieves the instrumentation provider that defines<br />
the events for the security cache and the authorization<br />
provider. The provider logs the events to WMI<br />
and the event log.<br />
The CustomAuthorizationProviderData class<br />
and the CustomSecurityCacheProviderData class<br />
support custom property collections for custom<br />
providers.<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 Security Application Block.<br />
Table 4: Security Application Block Code Verification<br />
Code test case Implemented? Feature that is implemented<br />
Verify that, for<br />
each request,<br />
the application<br />
block only<br />
creates one<br />
instance of<br />
a class that<br />
derives from<br />
the AuthorizationProvider<br />
or that<br />
implements<br />
the IAuthorizationProvider<br />
interface.<br />
Yes<br />
The AuthorizationFactory class creates instances of classes<br />
that derive from the AuthorizationProvider class as well as instances<br />
of classes that implement the IAuthorizationProvider<br />
interface. It does this by calling the AuthorizationProviderFactory<br />
class. The AuthorizationProviderFactory class derives<br />
from the NameTypeFactoryBase class. This class creates a<br />
new instance of a provider for every request. This derivation is<br />
shown in the following code.<br />
public class AuthorizationProviderFactory : NameTyp<br />
eFactoryBase{}<br />
continued