I'm building some NUnit tests for the business classes in my ASP.NET
application. Some of the business classes use Session to store information.
NUnit does not generate a Session, so the code below bombs when a
HttpContext.Current.Session["some_key"];
Any suggestions on the best alternative for working around this, without
making a hack job out of the code? I can check the HttpContext.Current and
check to see if it is null, but where/how should I store the alternative
session information? Not sure if it is relevant, but I'm not using
NUnitAsp.
Thanks in advance.
Mark 4 3477
HI Mark:
There are a couple tips on this page: http://home.iprimus.com.au/lachlanb/nunitasp/nunit.html
--
Scott http://www.OdeToCode.com/blogs/scott/
On Wed, 2 Mar 2005 16:10:28 -0600, "Mark" <Ma**@nowhere.com> wrote: I'm building some NUnit tests for the business classes in my ASP.NET application. Some of the business classes use Session to store information. NUnit does not generate a Session, so the code below bombs when a
HttpContext.Current.Session["some_key"];
Any suggestions on the best alternative for working around this, without making a hack job out of the code? I can check the HttpContext.Current and check to see if it is null, but where/how should I store the alternative session information? Not sure if it is relevant, but I'm not using NUnitAsp.
Thanks in advance. Mark
you should switch to the factory model for session management, them you can
supply a mock session handler for the unit tests.
-- bruce (sqlwork.com)
"Mark" <Ma**@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
| I'm building some NUnit tests for the business classes in my ASP.NET
| application. Some of the business classes use Session to store
information.
| NUnit does not generate a Session, so the code below bombs when a
|
| HttpContext.Current.Session["some_key"];
|
| Any suggestions on the best alternative for working around this, without
| making a hack job out of the code? I can check the HttpContext.Current
and
| check to see if it is null, but where/how should I store the alternative
| session information? Not sure if it is relevant, but I'm not using
| NUnitAsp.
|
| Thanks in advance.
| Mark
|
|
Mark wrote: I'm building some NUnit tests for the business classes in my ASP.NET application. Some of the business classes use Session to store information. NUnit does not generate a Session, so the code below bombs when a
HttpContext.Current.Session["some_key"];
Any suggestions on the best alternative for working around this, without making a hack job out of the code?
You've tightly coupled your business logic with your web UI -- and
found out that it's a bad idea. Just don't do that. Pass your business
objects the data they need and keep them free of all ASP.NET/HTTP/web
stuff. All of a sudden, your code becomes clean & testable :-)
Cheers,
-- http://www.joergjooss.de
mailto:ne********@joergjooss.de
Have you seen
SWExplorerAutomation(http:\\home.comcast.net/~furmana/SWIEAutomation.htm)?
You can write tests by automating IE. It means that all functionality
of Web Application can be tested, including client scripts.
Mark wrote: I'm building some NUnit tests for the business classes in my ASP.NET application. Some of the business classes use Session to store
information. NUnit does not generate a Session, so the code below bombs when a
HttpContext.Current.Session["some_key"];
Any suggestions on the best alternative for working around this,
without making a hack job out of the code? I can check the
HttpContext.Current and check to see if it is null, but where/how should I store the
alternative session information? Not sure if it is relevant, but I'm not using NUnitAsp.
Thanks in advance. Mark This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sky Kim |
last post by:
Hi, all.
I've know NUnit for a while, now I try to use it.
Most of application I develope is data base driven.
I want to test data layer most with may input and checking the result, then
compare...
|
by: Johan Nedin |
last post by:
Hello!
I have a problem with SQLSession state on my ASP.NET pages.
SQLSession state behaves very different from InProcess session state,
which I think is very bad.
I can understand some of...
|
by: tshad |
last post by:
I have been using the default session state (InProc) and have found that I
have been loosing my information after a period of time (normally 20
minutes).
Is there anyway to find out how much...
|
by: McGeeky |
last post by:
Is there a way to get a user control to remember its state across pages? I
have a standard page layout I use with a header and footer as user controls.
Each page uses the same layout by means of...
|
by: Mike Hofer |
last post by:
I need some advice, folks, and I'm hoping you can provide it.
First off, a few disclaimers:
1.) I am an ardant advocate of code quality. Especially, my own.
2.) I am maintaining a massive...
|
by: Glenn |
last post by:
Hi
I've been experimenting with managing state using the Session object. I've
created a simple WS with a couple of methods, one which sets a string
value, another that retrieves it.
Each...
|
by: manjitsarma |
last post by:
In doing NUNIT Testing(In the RUN event of NUNIT),I am losing the value of the OBJECT whose methods and variables I need to check.The OBJECT is 'MAP' here.What I should do to solve the problem ?...
|
by: Sonali24 |
last post by:
Hi All,
I am not sure whether write place to post this in this forum.
I am new to Nunit..
I am facing problems to test or instantiate the session variables.
I used...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |