0
AdvertisementDataContext db = new AdvertisementDataContext(); //make an object so that we can retrieve data from database
public ActionResult Index()
{
var advertisement = db.Advertisements.ToArray(); // retrieve data from database
return View(advertisement); // we return the object to the index view
}
내가이 오류를 제공 작동하지 않을 것 code.but에 대한 테스트 케이스를 쓰기반환보기를 확인하기 위해 Unittest 케이스를 작성하는 방법은 무엇입니까?
Error 1 The type 'System.Data.Entity.DbContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
내 시험 방법은
[TestMethod]
public void TestIndex() {
Bartering.Models.AdvertisementDataContext db = new Bartering.Models.AdvertisementDataContext();
AdvertisementController controller = new AdvertisementController();
ViewResult result = controller.Index() as ViewResult;
Assert.AreEqual(db.Advertisements, result.ViewBag);
}
이다이 문제를 해결하거나 도와 저를 도와주세요 그 방법에 대한 테스트 케이스를 작성하십시오.
오류 메시지는 당신이해야 할 일을 정확히 알려줍니다 : 'EntityFramework' 어셈블리에 대한 참조를 추가하십시오. 너 그거 해봤 니? –
또한 '사용'에 대한 http://msmvps.com/blogs/jon_skeet/archive/2013/09/19/casting-vs-quot-as-quot-embracing-exceptions.aspx를 읽어보십시오. –