예제 #1
0
 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();
     }
 }
예제 #2
0
        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>();
        }
예제 #3
0
 public List<Trip.Trip> GetFriendsTrips(User user, ITripDao tripDao)
 {
     var tripList = new List<Trip.Trip>();
     if (IsFriendOf(user))
     {
         tripList = tripDao.FindTripsByUser(this);
     }
     return tripList;
 }
예제 #4
0
 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 ();
 }
예제 #5
0
        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);
        }
예제 #6
0
        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>();
        }
예제 #7
0
        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);
        }
예제 #8
0
 public User GetLoggedUser(User user)
 {
     throw new DependendClassCallDuringUnitTestException(
         "UserSession.GetLoggedUser() should not be called in an unit test");
 }
예제 #9
0
 public bool IsFriendsWith(User loggedUser)
 {
     return _friends.Any(friend => friend == loggedUser);
 }
예제 #10
0
 public void AddFriend(User user)
 {
     _friends.Add(user);
 }
예제 #11
0
 public bool IsFriendWith(User user)
 {
     return friends.Contains(user);
 }
예제 #12
0
 public List<Trip> GetTripsByUser(User.User user)
 {
     var loggedUser = GetLoggedUser();
     return FindtripsByFriendsOf (user, loggedUser);
 }
 public MockUserSession(User.User loggedUser)
 {
     _loggedUser = loggedUser;
 }
예제 #14
0
 public List<Trip> FindTripsByUser(User.User user)
 {
     return TripDAO.FindTripsByUser(user);
 }
예제 #15
0
 public bool IsFriendOf(User loggedUser)
 {
     return Enumerable.Contains(GetFriends(), loggedUser);
 }
예제 #16
0
 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;
 }