Created
September 14, 2012 03:06
-
-
Save adamtuliper/3719567 to your computer and use it in GitHub Desktop.
Strongly typed caching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Test_Add_And_Remove_Item_From_Cache_Pass() | |
{ | |
Customer customer = new Customer | |
{ | |
CustomerId = new Random(DateTime.Now.Millisecond).Next(), | |
FirstName = "Mary", | |
LastName = "Doe", | |
Address = "555 Main St.", | |
City = "Austin", | |
State = "TX", | |
Zip = "73301", | |
EmailAddress = "mary@internal" | |
}; | |
string customerId = customer.CustomerId.ToString(); | |
//Act (add and remove from cache, then attempt to retrieve) | |
_cache.Add(customerId, customer, 100); | |
_cache.Remove(customerId); | |
var cachedCustomer = _cache.Get<Customer>(customerId); | |
//Assert - should be null | |
Assert.IsNull(cachedCustomer); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment