public void BrowseTest() { var mediaDal = new MockMediaDal { ThrowError = false }; var controller = new BorrowController(new MockBorrowDal(), mediaDal, new MockMemberDal()); var result = (ViewResult)controller.Browse(); Assert.AreEqual("Browse", result.ViewName); var actualList = (List <Media>)result.Model; Assert.AreEqual(1, actualList.Count); }
public void BrowseTestWithException() { var mediaDal = new MockMediaDal { ThrowError = true }; var controller = new BorrowController(new MockBorrowDal(), mediaDal, new MockMemberDal()); var result = (ViewResult)controller.Browse(); Assert.AreEqual(null, result.ViewName); Assert.AreEqual("Uh-oh.. something went wrong", result.ViewData["Error"]); var actualList = (List <Media>)result.Model; Assert.AreEqual(0, actualList.Count); }