public void It_should_ask_the_complaint_service_for_a_paged_list_of_complaints_as_a_part_of_the_friend_action()
        {
            //Arrange
            StubContext();

            long friendId = 1;
            var pagingInfo = TestUtilities.GetPagingInformation();
            IPagedList<Complaint> complaints = TestUtilities.GetPagedTestComplaints(pagingInfo);
            var friend = new User() { FacebookId = friendId };

            A.CallTo(() => _userService.FindByFacebookId(friendId)).Returns(friend);
            A.CallTo(() => _complaintService.GetComplaintsByFacebookId(pagingInfo, friendId)).Returns(complaints);

            //Act
            _controller.Friend(friendId, pagingInfo);

            //Assert
            A.CallTo(() => _complaintService.GetComplaintsByFacebookId(pagingInfo, friendId)).MustHaveHappened(Repeated.Exactly.Once);
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (FacebookService.IsAuthenticated)
            {
                var facebookId = FacebookService.CurrentFacebookUserId;

                var user = UserService.FindByFacebookId(facebookId);

                if (user == null)
                {
                    var me = FacebookService.GetMe();

                    user = new User() {
                        Email = me.Email,
                        FacebookId = me.FacebookUserId,
                        Name = me.Name
                    };

                    UserService.Create(user);
                }
            }
        }
        public void It_should_return_a_view_as_a_part_of_the_friends_action()
        {
            //Arrange
            StubContext();

            long friendId = 1;
            var pagingInfo = TestUtilities.GetPagingInformation();
            IPagedList<Complaint> complaints = TestUtilities.GetPagedTestComplaints(pagingInfo);
            var friend = new User() { FacebookId = friendId };

            A.CallTo(() => _userService.FindByFacebookId(friendId)).Returns(friend);
            A.CallTo(() => _complaintService.GetComplaintsByFacebookId(pagingInfo, friendId)).Returns(complaints);

            //Act
            var result = _controller.Friend(friendId, pagingInfo);

            //Assert
            result.Should().BeOfType<ViewResult>();
        }