ASP.NET website에 게시 된 비디오를 사용하여 ASP.NET MVC을 배우려고 노력했으며 단위 테스트를 수행하는 데 문제가 있습니다. 이것은 다음과 같은 오류와 함께 NUnit에 실패NUnit을 사용한 ASP.NET MVC 유닛 테스트
public ActionResult Index()
{
ViewData["Message"] = "Welcome to ASP.NET MVC!";
using (TrainingLogDataContext dc = new TrainingLogDataContext())
{
ViewData.Model = dc.Workouts.ToArray();
}
return View();
}
:
나는 객체의 배열을 가져 오는 LINQ to SQL를 사용하는 매우 간단한 컨트롤러가at TrainingLog.Models.TrainingLogDataContext..ctor() in C:\Webs\TrainingLog\TrainingLog\Models\TrainingLog.designer.cs:line 41
at TrainingLog.Controllers.HomeController.Index() in C:\Webs\TrainingLog\TrainingLog\Controllers\HomeController.cs:line 16
at TrainingLogTests.Controllers.HomeControllerTest.Index() in C:\Webs\TrainingLog\TrainingLog.Tests\Controllers\HomeControllerTest.cs:line 23
것 같아요 문제가 있다는 것입니다을 NUnit를 DataContext에 대한 연결 문자열을 web.config
에서 가져올 수 없습니다. 이 문제를 해결하는 가장 좋은 방법은 무엇입니까?
페이지를 실행할 때 제대로 작동하지만 NUnit에서 단위 테스트가 실패합니다.
나를 위해 작동합니다. 감사합니다. :) – melaos