public void People_Pets_Return_Correct_View() { // Arrange var peoplePetsTestController = new PeoplePetsController(); //Action var result = peoplePetsTestController.PeoplePets() as ViewResult; // Assert Assert.AreEqual("PeoplePets", result.ViewName); }
public void People_Pets_Controller_Model_Test() { // Arrange var peoplePetsTestController = new PeoplePetsController(_Service.Object); //Action var result = peoplePetsTestController.PeoplePets() as ViewResult; // Assert Assert.IsInstanceOfType(result.ViewData.Model, typeof(PetsViewModel)); }
public void FemaleCatsTest() { //Arrange var testPeoplePetsController = new PeoplePetsController(_Service); //Action var result = testPeoplePetsController.PeoplePets() as ViewResult; //Assert var testPeoplePetsViewModel = (PetsViewModel)result.ViewData.Model; foreach (var femaleCats in testPeoplePetsViewModel.FemaleCats) { Assert.AreEqual("Cat", femaleCats.Type); } }
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); }