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