Example #1
0
        public Task <ITwitterResult <IUserDTO> > GetAuthenticatedUser(IGetAuthenticatedUserParameters parameters, ITwitterRequest request)
        {
            var query = _userQueryGenerator.GetAuthenticatedUserQuery(parameters);

            request.Query.Url        = query;
            request.Query.HttpMethod = HttpMethod.GET;

            return(_twitterAccessor.ExecuteRequest <IUserDTO>(request));
        }
Example #2
0
        public async Task GetAuthenticatedUser_ReturnsUserDTOAsync()
        {
            // Arrange
            var queryExecutor = CreateUserQueryExecutor();

            var url            = TestHelper.GenerateString();
            var parameters     = new GetAuthenticatedUserParameters();
            var request        = A.Fake <ITwitterRequest>();
            var expectedResult = A.Fake <ITwitterResult <IUserDTO> >();

            request.ExecutionContext.TweetMode = TweetMode.Extended;

            A.CallTo(() => _fakeUserQueryGenerator.GetAuthenticatedUserQuery(parameters)).Returns(url);
            A.CallTo(() => _fakeTwitterAccessor.ExecuteRequestAsync <IUserDTO>(request)).Returns(expectedResult);

            // Act
            var result = await queryExecutor.GetAuthenticatedUserAsync(parameters, request);

            // Assert
            Assert.Equal(result, expectedResult);
            Assert.Equal(request.Query.Url, url);
            Assert.Equal(HttpMethod.GET, request.Query.HttpMethod);
        }