public void SortedPetsTest() { //Arrange Mock <IProcessJsonDataService> _processMoqJsonDataService = new Mock <IProcessJsonDataService>(); _processMoqJsonDataService.Setup(service => service.GetPeoplePetsData()) .Returns(GetMocPetsViewModelData()); var testPeoplePetsController = new PeoplePetsController(_processMoqJsonDataService.Object); var moqResult = testPeoplePetsController.PeoplePets() as ViewResult; PetsViewModel moqPeoplePets = (PetsViewModel)moqResult.ViewData.Model; PetsViewModel peoplePets = _Service.GetPeoplePetsData(); //Action var serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); var expectedResult = serializer.Serialize(moqPeoplePets); var actualResult = serializer.Serialize(peoplePets); //Assert Assert.AreEqual(expectedResult, actualResult); }
// GET: PeoplePets public ActionResult PeoplePets() { return(View("PeoplePets", _Service.GetPeoplePetsData())); }