Ünite testlerimden birinde, tüm genel yöntemlerin ActionResult türünü döndürüp döndürmediğini kontrol etmek istiyorum. Ben iddia kesme noktası ayarlamakC# Birim Testinde Type yerine RuntimeType
Assert.IsInstanceOfType failed. Expected type:<System.Web.Mvc.ActionResult>. Actual type:<System.RuntimeType>.
: Aşağıdaki hata ile
[Authorize]
public ActionResult MyList()
{
return View();
}
:
[TestMethod]
public void Public_Methods_Should_Only_Return_ActionResults()
{
MethodInfo[] methodInfos = typeof(MyController).GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
foreach (MethodInfo methodInfo in methodInfos)
{
Assert.IsInstanceOfType(methodInfo.ReturnType, typeof(System.Web.Mvc.ActionResult));
}
}
Bu test MyController ilk yöntem üzerinde patlarsa: İşte benim test yöntemi var ve methodInfo.ReturnType türünü yazın ve bu ActionResult olduğunu.
Testin neden patladığını ve ne işe yaraması gerektiğini öğrenmek isteyen var mı? peşin
sayesinde yerine Assert.IsInstanceOfType ait MR
Çok teşekkür ederim. Şimdi istediğim gibi çalışıyor. –