public ActionResult EnleverAmi(string id, string username) { if (!id.IsNullOrWhiteSpace() && !username.IsNullOrWhiteSpace()) { var user = User as PrincessPrincipal; if (user != null) { var fs = new FriendService(user.Token); fs.RemoveFriend(id, username); } } return(RedirectToAction("Index", "Home")); }
public void CallUserFriendRepository_Delete() { // Arrange int currentUserId = 1; int friendId = 3; var mockedUserFriendRepository = new Mock <IEFRepository <UserFriend> >(); var friendships = new List <UserFriend>() { new UserFriend() { UserId = currentUserId, FriendId = friendId }, new UserFriend() { UserId = friendId, FriendId = currentUserId } }.AsQueryable(); mockedUserFriendRepository.Setup(x => x.All).Returns(friendships); var mockedUserRepository = new Mock <IEFRepository <CustomUser> >(); var mockedUserFriendFactory = new Mock <IUserFriendFactory>(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var friendService = new FriendService( mockedUserFriendRepository.Object, mockedUserRepository.Object, mockedUserFriendFactory.Object, mockedUnitOfWork.Object); // Act friendService.RemoveFriend(currentUserId, friendId); // Assert mockedUserFriendRepository.Verify(x => x.Delete(It.Is <UserFriend>(u => u.UserId == currentUserId && u.FriendId == friendId))); mockedUserFriendRepository.Verify(x => x.Delete(It.Is <UserFriend>(u => u.UserId == friendId && u.FriendId == currentUserId))); }