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.

186<br />

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

Table 3: Caching Application Block <strong>Test</strong> Code<br />

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

1 Add This is the code to add items to the cache.<br />

protected void AddItem_Click(object sender, EventArgs e)<br />

{<br />

// The cache element is created. The size is defined<br />

// by the TextBox2.Text.<br />

byte[] CacheObject = new byte[int.Parse(TextBox2.Text)];<br />

// The GetCacheManager method is called for each iteration.<br />

// The CacheManager is not cached. The call to GetCacheManager<br />

// passes it the type of caching store from<br />

// DropDownList3. SqlCacheManager uses SQL Server as the<br />

cache.<br />

// DefaultCacheManager is an in-memory cache.<br />

this.primitivesCache = CacheFactory.GetCacheManager(DropDownLi<br />

st3.SelectedItem.Value);<br />

this.absolutetime = DateTime.Now + TimeSpan.FromSeconds(60);<br />

switch (this.DropDownList1.SelectedIndex)<br />

{<br />

case 0:<br />

primitivesCache.Add(TextBox1.Text, CacheObject, this.Priority,<br />

new NullRefreshAction(), null);<br />

break;<br />

case 1:<br />

primitivesCache.Add(TextBox1.Text, CacheObject, this.Priority,<br />

new NullRefreshAction(),<br />

new AbsoluteTime(this.absolutetime));<br />

break;<br />

case 2:<br />

primitivesCache.Add(TextBox1.Text, CacheObject, this.Priority,<br />

new NullRefreshAction(),<br />

new SlidingTime(TimeSpan.FromSeconds(5)));<br />

break;<br />

case 3:<br />

primitivesCache.Add(TextBox1.Text, CacheObject, this.Priority,<br />

new NullRefreshAction(),<br />

new ExtendedFormatTime("0 0 * * *"));<br />

break;<br />

case 4:<br />

primitivesCache.Add(TextBox1.Text, CacheObject, this.Priority,<br />

new NullRefreshAction(),<br />

new FileDependency(@"c:\pag\entlibtests\web30.config"));<br />

break;<br />

}<br />

}

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

Saved successfully!

Ooh no, something went wrong!