public void ChangeLastnameTest() { //Arrange int index = 0; var testUser = GetUserCollection().ElementAt(index); //Act userMockRepository.Setup(x => x.Get(index.ToString())).Returns(GetUserCollection().ElementAt(index)); mapper.Setup(x => x.Map <User>(It.IsAny <User>())).Returns(GetUserCollection().ElementAt(index)); userService.ChangeLastname(testUser, "NewLastname"); //Assert Assert.Equal(testUser.LastName, "NewLastname"); }