public void ChangeUsernameTest() { //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.ChangeUsername(testUser, "newname"); //Assert Assert.Equal(testUser.UserName, "newname"); }