In my application, the business logic is written in the page_load function itself and it does not return anything(void). In the page load, web method is called and the object is displayed on the ASP page. In any of these scenarios, no return type methods
are used. All the methods are void type only. So, I think its not possible to implement nunit in this scenario. Please suggest.
Hi,
I am implementing nunit in my project. I am not getting idea how to implement the nunit after studying the documentation on it. Most of my code is:
private void Page_Load(object sender, System.EventArgs e)
{
logger.Info("Loading the AgentDetails page");
this.InitialiseRequest();
//this.Title = "Agent Details";
this.SetHeaderTabs(HeaderTabs1,1);
logger.Info("Webservice method 'getAgentDetails' is called from the Web References layer");
WSLayer.AgentDetails agtDet = this.WebService.getAgentDetails(this.AgentCode);
this.AgentName = agtDet.Subagent[0].Fullname;
this.SetTitleBar(HeaderTitleBar1);
this.SetAgentDetails(AgentDetails1);
logger.Info("End of Loading the AgentDetails page");
}
Could you please suggest me here? Can I write asserts inside this block itself?
First, do not under any circumstances include unit test code in your UI or code-behind. That is not what unit tests are for. Unit tests are for testing specific behavior of a class. For example, this tests the result of adding two numbers together:
[TestMethod]
public void Add_1And2_Returns3()
{
//arrange
Calculator calculator = new Calculator();
//act
int result = calculator.Add(1, 2);
//assert
Assert.AreEqual(3, result);
}
Unit testing is a very large subject about which entire books have been written. I would suggest picking up a copy of
The Art of Unit Testing.
In order to unit test in such a scenario, you need to extend NUnit either by using WaTiN. Previously you could have used NUnitAsp but development of this has been suspended.
Click "Mark as Answer" on the post that helped you.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
Member
1 Points
10 Posts
nunit
Feb 01, 2010 05:52 AM|psatishbabu|LINK
In my application, the business logic is written in the page_load function itself and it does not return anything(void). In the page load, web method is called and the object is displayed on the ASP page. In any of these scenarios, no return type methods are used. All the methods are void type only. So, I think its not possible to implement nunit in this scenario. Please suggest.
Hi,
I am implementing nunit in my project. I am not getting idea how to implement the nunit after studying the documentation on it. Most of my code is:
private void Page_Load(object sender, System.EventArgs e)
{
logger.Info("Loading the AgentDetails page");
this.InitialiseRequest();
//this.Title = "Agent Details";
this.SetHeaderTabs(HeaderTabs1,1);
logger.Info("Webservice method 'getAgentDetails' is called from the Web References layer");
WSLayer.AgentDetails agtDet = this.WebService.getAgentDetails(this.AgentCode);
this.AgentName = agtDet.Subagent[0].Fullname;
this.SetTitleBar(HeaderTitleBar1);
this.SetAgentDetails(AgentDetails1);
logger.Info("End of Loading the AgentDetails page");
}
Could you please suggest me here? Can I write asserts inside this block itself?
Participant
1530 Points
421 Posts
Re: nunit
Feb 01, 2010 10:51 AM|Aquaren|LINK
First, do not under any circumstances include unit test code in your UI or code-behind. That is not what unit tests are for. Unit tests are for testing specific behavior of a class. For example, this tests the result of adding two numbers together:
Unit testing is a very large subject about which entire books have been written. I would suggest picking up a copy of The Art of Unit Testing.
All-Star
44551 Points
13496 Posts
MVP
Re: nunit
Feb 03, 2010 07:52 AM|TATWORTH|LINK
In order to unit test in such a scenario, you need to extend NUnit either by using WaTiN. Previously you could have used NUnitAsp but development of this has been suspended.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239