I am trying to create a Unit Test for an MVC Cache. Currently, I created a new MockRepository (CacheManager is the wrapper class), and I am trying to figure out why the Get function returns null. My manager mentioned that he believes it has something to do with creating a mock HTTP context.
- Do I need to use a mock HTTP Context to do a unit test with a cache using Rhino?
- Is my current code correct, assuming that Get and Set actually do work as they are supposed to?
-
Can anyone explain to me how a cache works in this MVC context, so I can get a better understanding of coding?
// ARRANGE MockRepository mocks = new MockRepository(); CacheManager cache = mocks.Stub<CacheManager>(); cache.initialize(); String str = "world"; // ACT cache.Add<String>("hello", str); String hi = cache.Get<String>("hello"); // ASSERT Assert.AreEqual(str, hi);
Aucun commentaire:
Enregistrer un commentaire