Need information for creating unit test case in Business Logic of a web application
-
Tuesday, August 28, 2012 9:09 AM
HI,
I have a web application consisting of different layers for BI and DAL. The scenario is i need to create a test method on some of the BL methods. I am able to do that. the problem comes when i execute the test method.
Basically the BI test method uses abstracted DAL method to fetch data from the database. further the connection string is used depending on a session value. So i need to know hopw can i successfully run my tests.
Code ex for the scenario
Business layer test method
[testmethod()]
public void GetUserInfo{
..
actual= target.GetUserInfo(actual);
}
when i try to debug the test this target throws exception? the method Getuserinfo uses a class which needs connection string based on session.
All Replies
-
Wednesday, August 29, 2012 1:05 AMModerator
Hello Nauty,
Thank you for posting in the MSDN forum.
Based on your description, I would like to know if the abstract DAL method achieves to fetch data from the database. And does the abstract DAL method use connection string based on session? If you don’t unit test BL methods, can your web application fetch data from the database successfully?
I addition, I don’t understand you code actual= target.GetUserInfo(actual). What is the meaning of the actual? Whether the method you want to test is GetUserInfo method or not? If so, why the test method’s name is the same as the name of the method tested? And what do you want to test?
If possible, you can provide more information for example some detailed codes.
Here is a help link about creating and running unit tests for managed code:
http://msdn.microsoft.com/en-us/library/ms182532.aspx
Best regards,
Amanda Zhu [MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by Jack Zhai - MSFTMicrosoft Contingent Staff, Moderator Wednesday, September 05, 2012 2:50 AM
-
Monday, September 03, 2012 6:15 AMModerator
Hi Nauty,
I am writing to check the status of the issue on your side. What about this problem now?
If no help, would you mind letting us know more information about this issue? What exception did you get? You could try to debug your unit test and check which line code generated this issue.
Best Regards,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us

