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 Security Application Block 117<br />

<strong>Test</strong> case Result Automated test<br />

Verify that authorization<br />

providers<br />

and security<br />

cache providers<br />

can be created<br />

directly, without<br />

using a configuration<br />

Passed This test uses a constructor to create a AuthorizationRuleProvider<br />

object. The test then verifies that the object can perform<br />

authorizations. The process is similar for AzmanAuthorizationProvider<br />

objects and CachingStoreProvider object.<br />

[<strong>Test</strong>Method]<br />

public void CreateAuthRuleProviderDirect()<br />

{<br />

source.<br />

IAuthorizationRule ruleData= new AuthorizationRuleData<br />

("<strong>Test</strong>Rule","I:<strong>Test</strong>User");<br />

IDictionary<br />

ruleDict= new Dictionary (<br />

);<br />

ruleDict["<strong>Test</strong>Rule"]= ruleData;<br />

IAuthorizationRule ruleData1 = new AuthorizationRuleDa<br />

ta("<strong>Test</strong>Rule1", "I:<strong>Test</strong>User1");<br />

ruleDict["<strong>Test</strong>Rule1"] = ruleData1;<br />

IAuthorizationProvider provider = new AuthorizationRul<br />

eProvider(ruleDict);<br />

bool isAuthorized = provider.Authorize(new<br />

GenericPrincipal(new GenericIdentity("<strong>Test</strong>User"), new<br />

string[]{}),"<strong>Test</strong>Rule");<br />

Assert.IsTrue(isAuthorized);<br />

}<br />

continued

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

Saved successfully!

Ooh no, something went wrong!