public void Details_EditionStatusTypeNotPublishedNorApproved_ReturnsNotFound() { // Arrange _mockEditionServices .Setup(x => x.GetEditionById(It.IsAny <int>(), null)). Returns(new EditionEntity { Status = EditionStatusType.Draft }); // Act var result = _sut.Details(1, null); // Assert var viewResult = ((ViewResult)result); Assert.IsInstanceOfType(result, typeof(ViewResult)); Assert.AreEqual(viewResult.ViewName, "NotFound"); Assert.IsInstanceOfType(viewResult.Model, typeof(ErrorModel)); //Assert.AreEqual(((ErrorModel)viewResult.Model).Message, "An event must have already been published or approved to be displayed."); }
public void Details_ValidRequest_ReturnsEditionDetailsModel() { // Arrange var @event = new Event(); @event.FillWithDefaultValues(); @event = _context.Events.Add(@event); var edition = new Edition(); edition.FillWithDefaultValues(@event); edition = _context.Editions.Add(edition); _context.SaveChanges(); // Act var result = _controller.Details(edition.EditionId, null); // Assert Assert.IsInstanceOf <EditionDetailsModel>(((ViewResult)result).Model); Assert.AreEqual(edition.EditionId, ((EditionDetailsModel)((ViewResult)result).Model).EditionId); }