public void GetMoviesByTheater_InternalServerError_Test() { var theaterServiceMock = new Mock <ITheaterService>(); string theater = ""; theaterServiceMock.Setup(x => x.GetMoviesByTheater(theater)).Throws <Exception>(); var controller = new TheaterController(theaterServiceMock.Object); var actualResult = controller.GetMoviesByTheater(theater); var result = (ObjectResult)actualResult; var asJson = JsonConvert.SerializeObject(result.Value); var deserialized = JsonConvert.DeserializeObject <Dictionary <string, object> >(asJson); Assert.IsTrue((bool)deserialized["Success"] == false); theaterServiceMock.VerifyAll(); }
public void GetMoviesByTheater_Successful_Test() { var theaterServiceMock = new Mock <ITheaterService>(); string theater = ""; theaterServiceMock.Setup(x => x.GetMoviesByTheater(theater)); var controller = new TheaterController(theaterServiceMock.Object); var actualResult = controller.GetMoviesByTheater(theater); 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(); }