public ActionResult Index() { var peopleDtoList = _personRepo.GetPeopleList(); var mapper = new PersonMapper(); var peopleList = mapper.MapPeopleList(peopleDtoList); return View(peopleList); }
public void MapPersonList_GivenListOfPersonDtos_ShouldReturnListOfPeople() { //---------------Set up test pack------------------- var expectedPeopleDtoList = CreatePeopleDtoList(); var mapper = new PersonMapper(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var actualPeopleList = mapper.MapPeopleList(expectedPeopleDtoList); //---------------Test Result ----------------------- Assert.AreEqual(expectedPeopleDtoList.Count, actualPeopleList.Count()); }
public void Index_GivenRepositoryHasPeople_ShouldReturnViewWithListOfPeople() { //---------------Set up test pack------------------- var repo = Substitute.For<IPersonRepository>(); var dtoList = new List<PersonDto>(); repo.GetPeopleList().Returns(dtoList); var controller = new PersonController(repo); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var result = controller.Index() as ViewResult; //---------------Test Result ----------------------- Assert.IsNotNull(result); Assert.IsNotNull(result.Model as IEnumerable); var mapper = new PersonMapper(); var peopleList = mapper.MapPeopleList(dtoList); CollectionAssert.AreEqual((IEnumerable)result.Model, peopleList); }