views:

327

answers:

1

I'm using ASP.NET to build an application and the latest version of NUNIT framework to test it. I'm constructing a User Control to build a custom menu. That control at some point checks whehter a specific object exists in the Session Collection or not to add some elements to the menu.

The exact functionality it provides is this: if the registered user is a regular user display the regular set of links, if the registered user is a administrator add extra links to the already displayed links. The control works as expected.

My problem:
I want to take the control outside the web application, and test it separately inside the NUNIT testing framework. My only concern is that it relies on the existence of the Session object. I don't know how to simulate it inside a nunit test method, if its possible or are there alternative solutions I haven't thought of.

+2  A: 

You will need stroke the framework in the right direction but you can do this by mocking the http context.

I tend to wrap operations like these in a custom class I can more easily mock.

As an alternative you can probably use mstest's web tests to achieve the same results.

Cristian Libardo
It's the test framework included in visual studio 2008. It's similar to NUnit, but different =)
Cristian Libardo
Thank you for your answer
Nikola Stjelja