Click here to Skip to main content
15,888,590 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to create unit test for controller. in my controller i have following codes...


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Crossover.SmallApps.Controllers
{
public class SkillsController : Controller
{
//
// GET: /Skills/

public ActionResult Index(int? id)
{
if (id.HasValue)
return View(DBHelper.Skills.Select(id.Value));
return View();

}
public JsonResult All(int? id)
{

return Json(DBHelper.Skills.Select());
}

public JsonResult Details(int id)
{
return Json(DBHelper.Skills.Select(id));
}
public ActionResult Update(Utility.Entity.Skills skills)
{
Utility.Entity.Skills obj = DBHelper.Skills.Select(skills.Id);
obj.Name = skills.Name;
DBHelper.Skills.Update(obj);
return new HttpStatusCodeResult(200, "OK");

}
public ActionResult Add(Utility.Entity.Skills skills)
{
DBHelper.Skills.Add(new Utility.Entity.Skills
{
Name=skills.Name
});
return new HttpStatusCodeResult(200, "OK");

}

}
}


what i want is to create unit testing for all methods above.your little help will be great help for me thankyou... :)
Posted
Updated 29-Oct-13 3:40am
v2

1 solution

 
Share this answer
 
Comments
kysor 29-Oct-13 9:59am    
that was quite helpful.but i want some specific solution for
public ActionResult Index(int? id)
{
if (id.HasValue)
return View(DBHelper.Skills.Select(id.Value));
return View();

}
-thankyou
hardikMSit 31-Oct-13 15:42pm    
thanks. thants a nice link :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900