0
我确实为以下方法生成了测试用例;它返回Action结果 - 一个json“Success”字符串。如何修改生成的脚本?写单位返回行动结果的方法的测试用例
public ActionResult LoginClick(string username, string password)
{
LoginRepo loginrepo = new LoginRepo();
BL bl = new BL();
bool loginStatus = loginrepo.CheckLogin(username, password);
if (loginStatus)
{
bl.SetSessionVariable("Username", username);
return Json(new { Status = "Success" }, JsonRequestBehavior.AllowGet);
}
return Json(new { Status = "Failed" }, JsonRequestBehavior.AllowGet);
}
以下是生成的测试用例。
[TestMethod()]
[HostType("ASP.NET")]
[UrlToTest("http://localhost:1280")]
public void LoginClickTest()
{
LoginController target = new LoginController(); // TODO: Initialize to an appropriate value
string username = null; // TODO: Initialize to an appropriate value
string password = null; // TODO: Initialize to an appropriate value
ActionResult expected = null ; // TODO: Initialize to an appropriate value
ActionResult actual;
actual = target.LoginClick(username, password);
Assert.AreEqual(expected, actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}
我该如何修改它以便它可以成功运行?既然它的行为结果和数据是json字符串应该预期什么,实际结果?我应该如何写assert?
他回答有帮助吗? – SBirthare 2014-10-31 06:13:59