Testing ASP.NET Session state part 2

After publishing the first example I thought I’d better show how to check the actual values in the cache too…
       
static void Main(string[] args)
        {
            Page page = new Page();
            MockManager.Init();
            MockObject sessionMock = MockManager.MockObject(typeof(HttpSessionState));
            Mock pageMock = MockManager.MockAll(page.GetType());
            pageMock.ExpectGet("Session", sessionMock.Object);
            sessionMock.ExpectGetIndex("ValueInIndex").Args("IndexKey");
            string value = (string)page.Session["IndexKey"];
            Console.WriteLine(value);
            Console.ReadKey();
            MockManager.Verify();
            MockManager.ClearAll();
        }

Advertisements
This entry was posted in TypeMock. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s