public void GetSkillsPartialView_ReturnPartialView_WithCorrectModel() { //Arrange var technologies = new List <Technology>() { new Technology(), new Technology() }; var technologyLogicMock = new Mock <ITechnologyLogic>(); technologyLogicMock.Setup(logic => logic.GetTechnologiesToShowInAboutMePage()).Returns(technologies); var aboutMeLogicMock = new Mock <IAboutMeLogic>(); AboutMeController controllerUnderTests = new AboutMeController(aboutMeLogicMock.Object, technologyLogicMock.Object); //Act var result = controllerUnderTests.GetSkillsPartialView(); //Assert var partialViewResult = Assert.IsType <PartialViewResult>(result); var model = Assert.IsType <List <Technology> >(partialViewResult.Model); Assert.Equal(technologies.Count, model.Count); }
public void GetSkillsPartialView_ReturnPartialView_WithEmptyModel_WhenLogicReturnNull() { //Arrange var technologyLogicMock = new Mock <ITechnologyLogic>(); technologyLogicMock.Setup(logic => logic.GetTechnologiesToShowInAboutMePage()).Returns((List <Technology>)null); var aboutMeLogicMock = new Mock <IAboutMeLogic>(); AboutMeController controllerUnderTests = new AboutMeController(aboutMeLogicMock.Object, technologyLogicMock.Object); //Act var result = controllerUnderTests.GetSkillsPartialView(); //Assert var partialViewResult = Assert.IsType <PartialViewResult>(result); var model = Assert.IsType <List <Technology> >(partialViewResult.Model); Assert.Empty(model); }