Im 지금 TDD를 배우기 시작했습니다. 그리고 컨트롤러를 테스트하는 데 몇 가지 문제가 있습니다. 그래서, 나는 설명하려고 노력할 것이다. 여기IoC를 사용하여 컨트롤러 테스트
public AccountController(IStoreService storeService)
{
_storeService = storeService;
}
public virtual ActionResult RenderBalance()
{
var model = _storeService.GetStorePageBalanceModel();
return PartialView("MyControl", model);
}
내가 내 RenderBalance 동작을 테스트 할 :
이 public class when_balance_renders
{
private static Mock<IStoreService> storeService = new Mock<IStoreService>();
private static AccountController controller;
private static ActionResult result;
private Establish context =() =>
{
controller = new AccountController(storeService.Object);
result = controller.RenderBalance();
};
private It should_be_not_null_result =() => { result.ShouldNotBeNull(); };
}
하지만이 코드가 작동하지 않습니다 나는 컨트롤러를 가지고있다. 디버그 모드에서이 오류가 있습니다. 파일 또는 어셈블리 또는 해당 종속성 중 하나를로드 할 수 없습니다. 잘못된 형식의 프로그램을로드하려고했습니다.
어떻게 수정합니까? 그리고 컨트롤러 테스트에 대한 몇 가지 권장 사항을 알려줄 수 있습니까? 감사합니다, Nogin Anton. 그냥 TDD 함께 시작하는 경우이 파일이나 어셈블리 또는 해당 종속성 중 하나를로드 할 수 없습니다이 오류가있는 경우 또한 여기 http://martinfowler.com/articles/mocksArentStubs.html
을 지적