public void GetReturnsNotFound() { // Arrange var mockRepository = new Mock <IFestivalRepository>(); var controller = new FestivalsController(mockRepository.Object); // Act IHttpActionResult actionResult = controller.GetById(10); // Assert Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult)); }
public void GetReturnsProductWithSameId() { // Arrange var mockRepository = new Mock <IFestivalRepository>(); mockRepository.Setup(x => x.GetById(42)).Returns(new Festival { Id = 42 }); var controller = new FestivalsController(mockRepository.Object); // Act IHttpActionResult actionResult = controller.GetById(42); var contentResult = actionResult as OkNegotiatedContentResult <Festival>; // Assert Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); Assert.AreEqual(42, contentResult.Content.Id); }