public void TestDetailNotFound() { // Arrange BookController controller = new BookController(); // Act ViewResult result = controller.Details(-15) as ViewResult; // Assert Assert.IsNull(result); }
public void TestDetailView() { // Arrange BookController controller = new BookController(); // Act ViewResult result = controller.Details(1) as ViewResult; // Assert Assert.AreEqual("Details", result.ViewName); }
public void TestDetailsViewData() { // Arrange BookController controller = new BookController(); // Act ViewResult result = controller.Details(1) as ViewResult; BookTbl product = (BookTbl)result.ViewData.Model; // Assert Assert.AreEqual(1, product.Id); }
public void Details_ModelIsABookObject() { // arrange var bookRep = new Mock <IRepository <Book> >(); bookRep.Setup(m => m.Get(It.IsAny <QueryOptions <Book> >())) .Returns(new Book { BookAuthors = new List <BookAuthor>() }); var unit = new Mock <IBookstoreUnitOfWork>(); unit.Setup(m => m.Books).Returns(bookRep.Object); var controller = new BookController(unit.Object); // act var model = controller.Details(1).ViewData.Model as Book; // assert Assert.IsType <Book>(model); }