public List<Trip> GetTripsByUser(User.User user) { List<Trip> tripList = new List<Trip>(); User.User loggedUser = UserSession.GetInstance().GetLoggedUser(); bool isFriend = false; if (loggedUser != null) { foreach(User.User friend in user.GetFriends()) { if (friend.Equals(loggedUser)) { isFriend = true; break; } } if (isFriend) { tripList = TripDAO.FindTripsByUser(user); } return tripList; } else { throw new UserNotLoggedInException(); } }
public List<Trip> GetTripsByUser(User.User user) { var userSearchResult = sessionService.GetLoggedUser(); if (userSearchResult.HasNotUser()) throw new UserNotLoggedInException(); return user.IsFriendOf(userSearchResult.User()) ? tripRepository.FindTripsByUser(user) : new List<Trip>(); }
public List<Trip.Trip> GetFriendsTrips(User user, ITripDao tripDao) { var tripList = new List<Trip.Trip>(); if (IsFriendOf(user)) { tripList = tripDao.FindTripsByUser(this); } return tripList; }
private List<Trip> FindtripsByFriendsOf(User.User user, User.User loggedUser) { foreach(User.User friend in user.GetFriends()) { if (friend.Equals(loggedUser)) { return tripDao.FindTripsByUser(user); } } return NoTrips (); }
public List<Trip> GetTripsByUser(User.User user) { var loggedUser = _userSession.GetLoggedUser(); if (loggedUser == null) throw new UserNotLoggedInException(); if (!user.IsFriendsWith(loggedUser)) return new List<Trip>(); return _userTripFinder.FindTripsByUser(user); }
public List<Trip> GetTripsByUser(User.User user) { User.User loggedUser = _userSessionWrapper.GetLoggedInUser(); if (loggedUser == null) throw new UserNotLoggedInException(); if (user.IsFriendWith(loggedUser)) return _tripDaoWrapper.FindTripsByUser(user); return new List<Trip>(); }
public void ShouldReturnTripsByLoggedUser() { var friend = new User (); var trip = new Trip (); userSession.Setup (x => x.GetLoggedUser()).Returns(friend); var user = new Mock<User>(); user.Setup (x => x.GetFriends()).Returns (new List<User> {friend, friend}); tripDao.Setup (x => x.FindTripsByUser (It.IsAny<User> ())).Returns (new List<Trip> { trip }); var tripsOfFiends = tripService.GetTripsByUser (user.Object); Assert.AreEqual(1, tripsOfFiends.Count); }
public User GetLoggedUser(User user) { throw new DependendClassCallDuringUnitTestException( "UserSession.GetLoggedUser() should not be called in an unit test"); }
public bool IsFriendsWith(User loggedUser) { return _friends.Any(friend => friend == loggedUser); }
public void AddFriend(User user) { _friends.Add(user); }
public bool IsFriendWith(User user) { return friends.Contains(user); }
public List<Trip> GetTripsByUser(User.User user) { var loggedUser = GetLoggedUser(); return FindtripsByFriendsOf (user, loggedUser); }
public MockUserSession(User.User loggedUser) { _loggedUser = loggedUser; }
public List<Trip> FindTripsByUser(User.User user) { return TripDAO.FindTripsByUser(user); }
public bool IsFriendOf(User loggedUser) { return Enumerable.Contains(GetFriends(), loggedUser); }
public bool IsUserLoggedIn(User user) { throw new DependendClassCallDuringUnitTestException( "UserSession.IsUserLoggedIn() should not be called in an unit test"); }
public bool IsUserLoggedIn(User.User user) { throw new System.NotImplementedException(); }
//protected override List<Trip.Trip> GetTripListByUser(User.User user) //{ // return _tripList; //} internal void SetLoggerUser(User.User user) { _loggerUser = user; }