Пример #1
0
        public void CreateRequestProcessor_Returns_ProperRequestProcessor()
        {
            var ctx = new TwitterContext(auth);

            var showQuery =
                from tweet in ctx.Status
                where tweet.Type == StatusType.Show
                select tweet;

            var statusProc = ctx.CreateRequestProcessor<Status>(showQuery.Expression);
            Assert.IsType(typeof(StatusRequestProcessor<Status>), statusProc);
        }
Пример #2
0
        public void CreateAccountRequestProcessorTest()
        {
            var ctx = new TwitterContext(auth);

            var queryResult = from tweet in ctx.Account select tweet;

            IRequestProcessor<Account> actual = ctx.CreateRequestProcessor<Account>(queryResult.Expression);
            Assert.IsType(typeof(AccountRequestProcessor<Account>), actual);
        }
Пример #3
0
        public void CreateStatusRequestProcessorTest()
        {
            var ctx = new TwitterContext(auth);

            var queryResult = from tweet in ctx.Status select tweet;

            IRequestProcessor<Status> actual = ctx.CreateRequestProcessor<Status>(queryResult.Expression);
            Assert.IsType(typeof(StatusRequestProcessor<Status>), actual);
        }
Пример #4
0
        public void CreateRequestProcessor_Returns_StreamingRequestProcessor()
        {
            var ctx = new TwitterContext(auth) {StreamingUrl = "https://stream.twitter.com/1/"};
            var execMock = new Mock<ITwitterExecute>();
            ctx.TwitterExecutor = execMock.Object;
            var streamingQuery =
                from tweet in ctx.Streaming
                where tweet.Type == StreamingType.Sample
                select tweet;

            var reqProc = ctx.CreateRequestProcessor<Streaming>(streamingQuery.Expression);

            Assert.IsType(typeof(StreamingRequestProcessor<Streaming>), reqProc);
            Assert.Equal("https://stream.twitter.com/1/", reqProc.BaseUrl);
            var streamingRequestProcessor = reqProc as StreamingRequestProcessor<Streaming>;
            if (streamingRequestProcessor != null)
                Assert.Equal(execMock.Object, streamingRequestProcessor.TwitterExecutor);
        }
Пример #5
0
        public void CreateRequestProcessor_Returns_UserStreamRequestProcessor()
        {
            var ctx = new TwitterContext(auth) {StreamingUrl = "https://userstream.twitter.com/1.1/"};
            var execMock = new Mock<ITwitterExecute>();
            ctx.TwitterExecutor = execMock.Object;
            var streamingQuery =
                from tweet in ctx.UserStream
                where tweet.Type == UserStreamType.User
                select tweet;

            var reqProc = ctx.CreateRequestProcessor<UserStream>(streamingQuery.Expression);

            Assert.IsType(typeof(UserStreamRequestProcessor<UserStream>), reqProc);
            var userStreamRequestProcessor = reqProc as UserStreamRequestProcessor<UserStream>;
            if (userStreamRequestProcessor != null)
                Assert.Equal("https://userstream.twitter.com/1.1/", userStreamRequestProcessor.UserStreamUrl);
            var streamRequestProcessor = reqProc as UserStreamRequestProcessor<UserStream>;
            if (streamRequestProcessor != null)
                Assert.Equal(execMock.Object, streamRequestProcessor.TwitterExecutor);
        }
Пример #6
0
        public void CreateRequestProcessor_Returns_RelatedResultsRequestProcessor()
        {
            var ctx = new TwitterContext(auth) {BaseUrl = "https://api.twitter.com/1.1/"};
            var execMock = new Mock<ITwitterExecute>();
            ctx.TwitterExecutor = execMock.Object;
            var resultsQuery =
                from tweet in ctx.RelatedResults
                where tweet.Type == RelatedResultsType.Show
                select tweet;

            var reqProc = ctx.CreateRequestProcessor<RelatedResults>(resultsQuery.Expression);

            Assert.IsType(typeof(RelatedResultsRequestProcessor<RelatedResults>), reqProc);
            Assert.Equal("https://api.twitter.com/1.1/", reqProc.BaseUrl);
        }
Пример #7
0
        public void CreateRequestProcessorNullExpressionTest1()
        {
            var ctx = new TwitterContext(auth);

            var ex = Assert.Throws<ArgumentNullException>(() => ctx.CreateRequestProcessor<Status>((Expression)null));

            Assert.Equal("Expression", ex.ParamName);
        }
Пример #8
0
        public void CreateSearchRequestProcessor_Returns_RawRequestProcessor()
        {
            var ctx = new TwitterContext(auth);

            var queryResult = from raw in ctx.RawQuery select raw;

            IRequestProcessor<Raw> actual = ctx.CreateRequestProcessor<Raw>(queryResult.Expression);
            Assert.IsType(typeof(RawRequestProcessor<Raw>), actual);
        }
Пример #9
0
        public void CreateFriendshipRequestProcessorTest()
        {
            var ctx = new TwitterContext(auth);

            var queryResult = from tweet in ctx.Friendship select tweet;

            IRequestProcessor<Friendship> actual = ctx.CreateRequestProcessor<Friendship>(queryResult.Expression);
            Assert.IsType(typeof(FriendshipRequestProcessor<Friendship>), actual);
        }
Пример #10
0
        public void CreateDirectMessageRequestProcessorTest()
        {
            var ctx = new TwitterContext(auth);

            var queryResult = from tweet in ctx.DirectMessage select tweet;

            IRequestProcessor<DirectMessage> actual = ctx.CreateRequestProcessor<DirectMessage>(queryResult.Expression);
            Assert.IsType(typeof(DirectMessageRequestProcessor<DirectMessage>), actual);
        }