Exemplo n.º 1
0
        /// <summary>
        /// Perform create favorite side-effect with raw data
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        private static void CreateFavoriteDemo(TwitterContext twitterCtx)
        {
            string status = "Testing LINQ to Twitter Raw Interface: " + DateTime.Now.ToString();
            var parameters = new Dictionary<string, string>();

            string queryString = "/favorites/create/25786742388.json";

            string result = twitterCtx.ExecuteRaw(queryString, parameters);

            Console.WriteLine("Result from create favorite: \n\n" + result);
        }
Exemplo n.º 2
0
        public void ExecuteRawRequest_Resolves_Too_Few_Url_Slashes()
        {
            const string BaseUrlWithoutTrailingSlash = "https://api.twitter.com/1.1/";
            const string QueryStringWithoutBeginningSlash = "statuses/update.json";
            const string FullUrl = "https://api.twitter.com/1.1/statuses/update.json";
            var authMock = new Mock<ITwitterAuthorizer>();
            var execMock = new Mock<ITwitterExecute>();
            execMock.SetupGet(exec => exec.AuthorizedClient).Returns(authMock.Object);
            var ctx = new TwitterContext(authMock.Object, execMock.Object, BaseUrlWithoutTrailingSlash, "");
            var parameters = new Dictionary<string, string>
            {
                { "status", "Testing" }
            };

            ctx.ExecuteRaw(QueryStringWithoutBeginningSlash, parameters);

            execMock.Verify(exec =>
                exec.PostToTwitter(
                    FullUrl,
                    parameters, It.IsAny<Func<string, Raw>>()), Times.Once());
        }
Exemplo n.º 3
0
        public void ExecuteRawRequest_Invokes_Executor_Execute()
        {
            var authMock = new Mock<ITwitterAuthorizer>();
            var execMock = new Mock<ITwitterExecute>();
            execMock.SetupGet(exec => exec.AuthorizedClient).Returns(authMock.Object);
            var ctx = new TwitterContext(authMock.Object, execMock.Object, "", "");
            const string QueryString = "statuses/update.json";
            var parameters = new Dictionary<string, string>
            {
                { "status", "Testing" }
            };

            ctx.ExecuteRaw(QueryString, parameters);

            execMock.Verify(exec =>
                exec.PostToTwitter(
                    "https://api.twitter.com/1.1/statuses/update.json",
                    parameters,
                    It.IsAny<Func<string, Raw>>()),
                Times.Once());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Perform update status side-effect with raw data
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        private static void UpdateStatusDemo(TwitterContext twitterCtx)
        {
            string status = "Testing LINQ to Twitter Raw Interface: " + DateTime.Now.ToString();
            var parameters = new Dictionary<string, string>
            {
                { "status", status }
            };

            string queryString = "/statuses/update.json";

            string result = twitterCtx.ExecuteRaw(queryString, parameters);

            Console.WriteLine("Result from update status: \n\n" + result);
        }
Exemplo n.º 5
0
        public void ExecuteRawRequest_Returns_Raw_Result()
        {
            var authMock = new Mock<ITwitterAuthorizer>();
            var execMock = new Mock<ITwitterExecute>();
            execMock.SetupGet(exec => exec.AuthorizedClient).Returns(authMock.Object);
            var ctx = new TwitterContext(authMock.Object, execMock.Object, "", "");
            const string QueryString = "statuses/update.json";
            var parameters = new Dictionary<string, string>
            {
                { "status", "Testing" }
            };
            const string ExpectedResult = "<status>xxx</status>";
            const string FullUrl = "https://api.twitter.com/1.1/statuses/update.json";
            execMock.Setup(exec => exec.PostToTwitter(FullUrl, parameters, It.IsAny<Func<string, Raw>>())).Returns(ExpectedResult);

            string actualResult = ctx.ExecuteRaw(QueryString, parameters);

            Assert.Equal(ExpectedResult, actualResult);
        }