public void Check_Modal_State_Is_Valid_Then_Response_Ok() { // Setup var mockTvShowService = new Mock <ITvShowService>(); mockTvShowService.Setup(x => x.GetFilteredTvShows(It.IsAny <List <TvShowRequest> >())).Returns( new List <TvShowResponse> { new TvShowResponse(new TvShow(new TvShowRequest { Drm = true, EpisodeCount = 3, ImageRequest = new ImageRequest(), Slug = "dd", Title = "ddd" })) }); // Action var controller = new TvShowController(mockTvShowService.Object); var actionResult = controller.Post(new ApiRequest <TvShowRequest>()); // Assert var okRes = actionResult as OkNegotiatedContentResult <ApiResponse <TvShowResponse> >; Assert.IsNotNull(okRes); }
public void Check_Bad_Request_With_Message_Is_Response_When_Invalid_Json_Is_Sent() { // Setup var controller = new TvShowController(); // Action controller.ModelState.AddModelError("test", "test"); var actionResult = controller.Post(new ApiRequest <TvShowRequest>()); // Assert var badRequest = actionResult as NegotiatedContentResult <ErrorResponse>; Assert.IsNotNull(badRequest); Assert.That(badRequest.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); Assert.That(badRequest.Content.Error, Is.EqualTo("Could not decode request: JSON parsing failed")); }