示例#1
0
        public async Task GetMutedUsers_ReturnsAllPages()
        {
            // arrange
            var accountController = CreateUserController();
            var parameters        = new GetMutedUsersParameters();

            var iterator           = accountController.GetMutedUsersIterator(parameters, A.Fake <ITwitterRequest>());
            var iteratorTestRunner = new TwitterUsersIteratorTestRunner(iterator);

            iteratorTestRunner.Arrange(A.CallTo(() => _fakeUserQueryExecutor.GetMutedUsers(It.IsAny <IGetMutedUsersParameters>(), It.IsAny <ITwitterRequest>())));

            // act
            await iteratorTestRunner.Act();

            // assert
            await iteratorTestRunner.Assert();
        }
示例#2
0
        public ITwitterPageIterator <ITwitterResult <IUserCursorQueryResultDTO> > GetMutedUsersIterator(IGetMutedUsersParameters parameters, ITwitterRequest request)
        {
            var twitterCursorResult = new TwitterPageIterator <ITwitterResult <IUserCursorQueryResultDTO> >(
                parameters.Cursor,
                cursor =>
            {
                var cursoredParameters = new GetMutedUsersParameters(parameters)
                {
                    Cursor = cursor
                };

                return(_userQueryExecutor.GetMutedUsers(cursoredParameters, new TwitterRequest(request)));
            },
                page => page.DataTransferObject.NextCursorStr,
                page => page.DataTransferObject.NextCursorStr == "0");

            return(twitterCursorResult);
        }
示例#3
0
        public void GetMutedUsersQuery_ReturnsExpectedQuery()
        {
            // Arrange
            var queryGenerator = CreateUserQueryGenerator();

            var parameters = new GetMutedUsersParameters
            {
                Cursor                = "42",
                PageSize              = 43,
                IncludeEntities       = true,
                SkipStatus            = false,
                CustomQueryParameters = { new Tuple <string, string>("hello", "world") }
            };

            // Act
            var result = queryGenerator.GetMutedUsersQuery(parameters);

            // Assert
            Assert.Equal(result, $"https://api.twitter.com/1.1/mutes/users/list.json?cursor=42&count=43&include_entities=true&skip_status=false&hello=world");
        }
示例#4
0
        public async Task GetMutedUsers_ReturnsUserDTOsAsync()
        {
            // Arrange
            var queryExecutor = CreateUserQueryExecutor();

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

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

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

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