2010-12-15 3 views
3

문자열을 반환하는 사용자 지정 ActionResult를 작성했습니다. 내가 단위 테스트 할 수있는 방법을 알아 내려고 노력하고있어.테스트 사용자 지정 ActionResult

나는 함께 해봤 다음

Test method Tests.Web.Mvc.ApplicationControllerTest.TestMessageBox threw exception: 
System.NotImplementedException: The method or operation is not implemented. 

스택 추적 : 나는 액션 결과를 테스트하려면 어떻게

System.Web.HttpContextBase.get_Response() 
System.Web.Mvc.JavaScriptResult.ExecuteResult(ControllerContext context) 
Tests.Web.Mvc.ResultExecutor.InvokeActionResult(ActionResult result) in D:\utv\Framework 4.0\Main\src\Framework.Tests\Web\Mvc\ResultExecutor.cs: line 22 
Tests.Web.Mvc.ApplicationControllerTest.TestMessageBox() in D:\utv\Framework 4.0\Main\src\Framework.Tests\Web\Mvc\ApplicationControllerTest.cs: line 46 

string ExecuteResult(ActionResult result) 
    { 
     var ctx = new ControllerContext(); 
     var writer = new StringWriter(); 
     var response = new HttpResponse(writer); 
     var context = new HttpContext(new HttpRequest(null, "http://localhost/uri/", null), response); 
     System.Web.HttpContext.Current = context; 


     result.ExecuteResult(ctx); 
     return writer.ToString(); 
    } 

그것은 나를 준다?

답변

0

MVC2 또는 MVC3에는 맞지 않습니다.

0

어쩌면 이것은 당신을 도울 수 있습니다

그것은 MVC의는 v1의

Integration testing an ASP.NET MVC application without web server or browser

, 나는 v2와 함께 아직 시도하지 않은 및 통합 테스트 프레임 워크에 대한 업데이 트가 있다면 나 또한 모른다 ,하지만 아마도 그것은 당신에게 유용 할 수 있습니다.

토마스

관련 문제