Last post Feb 03, 2010 07:52 AM by TATWORTH
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.
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.Title = "Agent Details";
logger.Info("Webservice method 'getAgentDetails' is called from the Web References layer");
WSLayer.AgentDetails agtDet = this.WebService.getAgentDetails(this.AgentCode);
this.AgentName = agtDet.Subagent.Fullname;
logger.Info("End of Loading the AgentDetails page");
Could you please suggest me here? Can I write asserts inside this block itself?
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:
public void Add_1And2_Returns3()
Calculator calculator = new Calculator();
int result = calculator.Add(1, 2);
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.
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.