Пример #1
0
        public ITwitterPageIterator <ITwitterResult <IIdsCursorQueryResultDTO> > GetRetweeterIdsIterator(IGetRetweeterIdsParameters parameters, ITwitterRequest request)
        {
            return(_pageCursorIteratorFactories.Create(parameters, cursor =>
            {
                var cursoredParameters = new GetRetweeterIdsParameters(parameters)
                {
                    Cursor = cursor
                };

                return _tweetQueryExecutor.GetRetweeterIds(cursoredParameters, new TwitterRequest(request));
            }));
        }
Пример #2
0
        public void GetRetweeterIds_ReturnsFromPageCursorIteratorFactories()
        {
            // arrange
            var parameters     = new GetRetweeterIdsParameters(42);
            var request        = A.Fake <ITwitterRequest>();
            var expectedResult = A.Fake <ITwitterPageIterator <ITwitterResult <IIdsCursorQueryResultDTO> > >();

            A.CallTo(() => _fakePageCursorIteratorFactories.Create(parameters, It.IsAny <Func <string, Task <ITwitterResult <IIdsCursorQueryResultDTO> > > >()))
            .Returns(expectedResult);

            var controller = CreateTweetController();
            var iterator   = controller.GetRetweeterIdsIterator(parameters, request);

            // assert
            Assert.Equal(iterator, expectedResult);
        }
        public void GetRetweeterIdsQuery_ReturnsExpectedQuery()
        {
            // Arrange
            var queryGenerator = CreateUserQueryGenerator();

            var parameters = new GetRetweeterIdsParameters(42)
            {
                Cursor   = "43",
                PageSize = 44,
                CustomQueryParameters = { new Tuple <string, string>("hello", "world") }
            };

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

            // Assert
            Assert.Equal(result, $"https://api.twitter.com/1.1/statuses/retweeters/ids.json?id=42&cursor=43&count=44&hello=world");
        }
Пример #4
0
        public async Task GetRetweeterIds_ReturnsUserIdsAsync()
        {
            // Arrange
            var queryExecutor = CreateUserQueryExecutor();
            var expectedQuery = TestHelper.GenerateString();

            var parameters     = new GetRetweeterIdsParameters(42);
            var request        = A.Fake <ITwitterRequest>();
            var expectedResult = A.Fake <ITwitterResult <IIdsCursorQueryResultDTO> >();

            A.CallTo(() => _fakeTweetQueryGenerator.GetRetweeterIdsQuery(parameters)).Returns(expectedQuery);
            A.CallTo(() => _fakeTwitterAccessor.ExecuteRequestAsync <IIdsCursorQueryResultDTO>(request)).Returns(expectedResult);

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

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