コード例 #1
0
 public void indexTest()
 {
     ContactController target = new ContactController(iCommentServices.Object);
     ActionResult actual;
     actual = target.index() as ActionResult;
     Assert.IsNotNull(actual);
 }
コード例 #2
0
 public void addTest()
 {
     ContactController target = new ContactController(iCommentServices.Object);
     Contacts contact = new Contacts() ;
     contact.city = "City";
     contact.country = "Country";
     contact.eMail = "email";
     contact.id = 10;
     contact.name = "name";
     contact.phone = null;
     ViewResult actual = target.add(contact) as ViewResult;
     TempDataDictionary tempData = actual.TempData as TempDataDictionary;
     ModelStateDictionary modelState = tempData["ModelState"] as ModelStateDictionary;
     Assert.AreEqual(actual.ViewName, "index");
     Assert.IsTrue(modelState.ContainsKey("phone"));
     contact.name = null;
     actual = target.add(contact) as ViewResult;
     tempData = actual.TempData as TempDataDictionary;
     modelState = tempData["ModelState"] as ModelStateDictionary;
     Assert.AreEqual(actual.ViewName, "index");
     Assert.AreEqual(2,modelState.Count);
 }