.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
sivanagamahesh

Home >> Forum >> www.DotNetSpark.com >> Post New QuestionBookmark and Share Subscribe to Forum

Unit testing issue

Posted By: moni     Posted Date: April 29, 2016    Points:5   Category :www.DotNetSpark.com
Hello All,

I'm writing a test case using Moq framework. I have following code

class employee
{
public void method (object test)
{
if (test = null) return;

else
{
do something;
}
}
}
}

I want to write a test case to test following :
if (test = null) return;

but not able to get how to do it

like in my Test class I'm writing following :
employee e;
e.method(null)

but how should I Assert to pass/fail of the test?
Can someone please help?

Responses
Author: Alankar             
Posted Date: June 06, 2016     Points: 20   

Assert.IsNull(test ,"test object is null");

If your test object is null then it will pass the test.

Author: dencypriya             
Posted Date: September 02, 2016     Points: 20   

Unit testing allows the programmer to refactor code or upgrade system libraries at a later date, and make sure the module still works correctly (e.g., in regression testing). The procedure is to write test cases for all functions and methods so that whenever a change causes a fault, it can be quickly identified. Unit tests detect changes which may break a design contract.
<a href="http://www.traininginsholinganallur.in/dot-net-training-in-chennai.html"> Dot Net Training in chennai </a>



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend