私はJamesBroomeのチュートリアルに従って、MSpecと関連するインフラストラクチャのいくつかを自分自身に教えてきました。最新バージョンのMSpec、MSpecMvc、およびASP.NET MVC 2を使用していますが、JPBoodhooのライブラリは使用していません。
このテストを実行すると
[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です。
コードをステップスルーすると、このメソッドのアサーション(ActionResultExtensions.cs
MSpecMVCのファイル内)に組み込まれます。
public static ViewResultAnd ShouldBeAView(this ActionResult actionResult)
{
actionResult.ShouldBeOfType<ViewResult>();
return new ViewResultAnd(actionResult as ViewResult);
}
actionResult
とはいえ、それはタイプであることが確認できますSystem.Web.Mvc.ViewResult
。別のコンピューターで同じツールを使用して他のテストを実行しましたが、現在の問題は発生していません。