저는 MSpec과 관련 인프라를 가르치기 위해 James Broome's tutorial을 따라 왔습니다. 최신 버전의 MSpec 인 MSpecMvc과 ASP.NET MVC 2를 사용하고 있으며 J.P Boodhoo의 라이브러리를 사용하지 않습니다.왜이 ViewResult가 MSpecMVC의 ShouldBeAView 어설 션을 실패합니까?
나는
[Subject(typeof(HomeController))]
public class when_the_home_controller_is_told_to_display_the_default_view
{
static string key;
static string message;
static ActionResult result;
static HomeController home_controller;
Establish context =() =>
{
key = "Message";
message = "Welcome to ASP.NET MVC!";
home_controller = new HomeController();
};
Because of =() => result = home_controller.Index();
It should_return_the_home_view =() => result.ShouldBeAView().And().ViewName.ShouldBeEmpty();
}
내가
홈보기 반환해야합니다 다음과 같은 오류 얻을이 테스트를 실행하면 :
유형의 System.Web.Mvc.ViewResult 될하지만입니다해야 실패를 형식 System.Web.Mvc.ViewResult
코드를 단계별 실행하면이 메서드에서 어설 션에 포함됩니다
public static ViewResultAnd ShouldBeAView(this ActionResult actionResult)
{
actionResult.ShouldBeOfType<ViewResult>();
return new ViewResultAnd(actionResult as ViewResult);
}
(MSpecMVC의 ActionResultExtensions.cs
파일),하지만 나는 actionResult
유형 System.Web.Mvc.ViewResult
의 것을 확인할 수 있습니다. 다른 컴퓨터에서 동일한 도구를 사용하여 다른 테스트를 실행했지만 현재 문제가 발생하지 않았습니다.
에 대해 모두 컴파일되었습니다. 제임스의 소스 코드를 얻었고 MSpec의 최신 버전 즉 0.3으로 대체했습니다. 4.0에 대해 컴파일되도록 노력할 것입니다. 귀하의 의견을 보내 주셔서 감사합니다. – DavidS
문제가 없습니다. Lemme는 그것이 어떻게 효과가 있었는지 안다! :) –
헤이 세르기, 내가 한 일은 네가 한 말을 따르는 것이었다. .NET Framework의 올바른 버전에 맞춰 컴파일하고 있는지 확인했습니다. :) – DavidS