Example #1
0
        public List <Trip> GetTripsByUser(User user)
        {
            Ensure.NotNull <UserNotLoggedInException>(userSession.GetLoggedUser(), "User is not logged in");

            return(user.IsFriendOf(userSession.GetLoggedUser())
                ? tripDAO.GetTripsBy(user)
                : NoTrips());
        }
Example #2
0
        public IEnumerable <Trip> GetTripsByUser(User user)
        {
            var loggedUser = userSession.GetLoggedUser();

            Ensure.NotNull <UserNotLoggedInException>(loggedUser, "User is not logged in");

            return(user.IsFriendOf(loggedUser)
                ? tripDAO.GetTripsBy(user)
                : NoTrips());
        }
Example #3
0
        private void allow_to_get_trips_when_user_is_a_friend()
        {
            var friend = Builder.User
                         .WithFriends(REGISTERED_USER, ANOTHER_USER)
                         .WithTrips(TO_LONDON, TO_KIOTO)
                         .Build();

            userSession.GetLoggedUser().Returns(REGISTERED_USER);
            tripDao.GetTripsBy(friend).Returns(friend.Trips());

            var trips = tripService.GetTripsByUser(friend);

            trips.Should().HaveCount(friend.Trips().Count);
        }
Example #4
0
        public void show_friend_trips()
        {
            var myFriend = UserBuilder
                .WithFriends(SOME_USER, REGISTERED_USER)
                .WithTrips(TO_ZARAGOZA, TO_BILBAO)
                .Build();

            userSession.GetLoggedUser().Returns(REGISTERED_USER);
            tripDAO.GetTripsBy(myFriend).Returns(myFriend.Trips());

            var trips = productionTripService.GetTripsByUser(myFriend);

            var expectedTripCount = 2;
            Assert.Equal(expectedTripCount, trips.Count);
        }
Example #5
0
        private void allow_to_get_back_trips_when_users_are_friends()
        {
            loggedInUser = REGISTER_USER;
            var friend = Builder.User
                         .WithFriends(ANOTHER_USER, loggedInUser)
                         .WithTrips(TO_ZARAGOZA, TO_BILBAO)
                         .Build();

            userSession.GetLoggedUser().Returns(loggedInUser);
            tripDAO.GetTripsBy(friend).Returns(friend.Trips());

            var trips = productionTripService.GetTripsByUser(friend);

            trips.Should().HaveCount(friend.Trips().Count);
        }