Quantcast
Channel: IT Bytes » TypeMock
Viewing all articles
Browse latest Browse all 6

Testing ASP.NET Session state part 2

$
0
0
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();
        }


Viewing all articles
Browse latest Browse all 6

Trending Articles