public void PostWrongPayload_ShouldGetErrorMessage() { var controller = new TvProgramController(); controller.Request = new HttpRequestMessage() { Content = new System.Net.Http.StringContent(GetWrongPayload()) }; controller.Configuration = new HttpConfiguration(); var actionResult = controller.Index(); var expectResponse = @" { ""error"": ""Could not decode request: JSON parsing failed"" } "; NegotiatedContentResult <failureResposneDto> negResult = Xunit.Assert.IsType <NegotiatedContentResult <failureResposneDto> >(actionResult); Xunit.Assert.Equal(HttpStatusCode.BadRequest, negResult.StatusCode); Xunit.Assert.Equal( Regex.Replace(expectResponse, @"\s+", ""), Regex.Replace(JsonConvert.SerializeObject(negResult.Content), @"\s+", "")); }
public void PostCorrectPayload_ShouldGetOk() { var controller = new TvProgramController(); controller.Request = new HttpRequestMessage() { Content = new System.Net.Http.StringContent(GetCorrectPayload()) }; controller.Configuration = new HttpConfiguration(); var actionResult = controller.Index(); var expectResponse = @" { ""response"": [ { ""image"": ""http://mybeautifulcatchupservice.com/img/shows/16KidsandCounting1280.jpg"", ""slug"": ""show/16kidsandcounting"", ""title"": ""16 Kids and Counting"" }, { ""image"": ""http://mybeautifulcatchupservice.com/img/shows/TheTaste1280.jpg"", ""slug"": ""show/thetaste"", ""title"": ""The Taste"" }, { ""image"": ""http://mybeautifulcatchupservice.com/img/shows/Thunderbirds_1280.jpg"", ""slug"": ""show/thunderbirds"", ""title"": ""Thunderbirds"" }, { ""image"": ""http://mybeautifulcatchupservice.com/img/shows/ScoobyDoo1280.jpg"", ""slug"": ""show/scoobydoomysteryincorporated"", ""title"": ""Scooby-Doo! Mystery Incorporated"" }, { ""image"": ""http://mybeautifulcatchupservice.com/img/shows/ToyHunter1280.jpg"", ""slug"": ""show/toyhunter"", ""title"": ""Toy Hunter"" }, { ""image"": ""http://mybeautifulcatchupservice.com/img/shows/Worlds1280.jpg"", ""slug"": ""show/worlds"", ""title"": ""World's..."" }, { ""image"": ""http://mybeautifulcatchupservice.com/img/shows/TheOriginals1280.jpg"", ""slug"": ""show/theoriginals"", ""title"": ""The Originals"" } ] } "; OkNegotiatedContentResult <successResposneDto> conNegResult = Xunit.Assert.IsType <OkNegotiatedContentResult <successResposneDto> >(actionResult); Xunit.Assert.Equal( Regex.Replace(expectResponse, @"\s+", ""), Regex.Replace(JsonConvert.SerializeObject(conNegResult.Content), @"\s+", ""), true); }