public void GetMovieTitleAndSummaryById_NullValue_Test() { var theaterServiceMock = new Mock <ITheaterService>(); Guid id = new Guid(); theaterServiceMock.Setup(x => x.GetMovieTitleAndSummaryById(id)).Throws <ArgumentException>(); var controller = new TheaterController(theaterServiceMock.Object); var actualResult = controller.GetMovieTitleAndSummaryById(id); var badRequestResult = (BadRequestObjectResult)actualResult; var asJson = JsonConvert.SerializeObject(badRequestResult.Value); var deserialized = JsonConvert.DeserializeObject <Dictionary <string, object> >(asJson); Assert.IsTrue((bool)deserialized["Success"] == false); theaterServiceMock.VerifyAll(); }
public void GetMovieTitleAndSummaryById_Successful_Test() { var theaterServiceMock = new Mock <ITheaterService>(); Guid id = new Guid(); theaterServiceMock.Setup(x => x.GetMovieTitleAndSummaryById(id)); var controller = new TheaterController(theaterServiceMock.Object); var actualResult = controller.GetMovieTitleAndSummaryById(id); var okResult = (OkObjectResult)actualResult; var asJson = JsonConvert.SerializeObject(okResult.Value); var deserialized = JsonConvert.DeserializeObject <Dictionary <string, object> >(asJson); Assert.IsTrue((bool)deserialized["Success"]); theaterServiceMock.VerifyAll(); }