public void GetParameters_Returns_Parameters()
        {
            var dmReqProc = new DirectMessageRequestProcessor <DirectMessage>();
            Expression <Func <DirectMessage, bool> > expression =
                dm =>
                dm.Type == DirectMessageType.Show &&
                dm.Count == 1 &&
                dm.MaxID == 789 &&
                dm.Page == 1 &&
                dm.SinceID == 123 &&
                dm.ID == 456 &&
                dm.IncludeEntities == true &&
                dm.SkipStatus == true &&
                dm.FullText == true;
            var lambdaExpression = expression as LambdaExpression;

            Dictionary <string, string> queryParams = dmReqProc.GetParameters(lambdaExpression);

            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair <string, string>("Type", ((int)DirectMessageType.Show).ToString(CultureInfo.InvariantCulture))));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair <string, string>("Count", "1")));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair <string, string>("MaxID", "789")));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair <string, string>("Page", "1")));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair <string, string>("SinceID", "123")));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair <string, string>("ID", "456")));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair <string, string>("IncludeEntities", "True")));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair <string, string>("SkipStatus", "True")));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair <string, string>("FullText", "True")));
        }
        public void GetParametersTest()
        {
            var dmProc = new DirectMessageRequestProcessor <DirectMessage>();
            var ctx    = new TwitterContext();

            var directMessages =
                from tweet in ctx.DirectMessage
                where tweet.Type == DirectMessageType.SentTo
                select tweet;

            var whereFinder      = new FirstWhereClauseFinder();
            var whereExpression  = whereFinder.GetFirstWhere(directMessages.Expression);
            var lambdaExpression = (LambdaExpression)((UnaryExpression)(whereExpression.Arguments[1])).Operand;

            lambdaExpression = (LambdaExpression)Evaluator.PartialEval(lambdaExpression);

            var queryParams = dmProc.GetParameters(lambdaExpression);

            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair <string, string>("Type", ((int)DirectMessageType.SentTo).ToString())));
        }
        public void GetParameters_Returns_Parameters()
        {
            var dmReqProc = new DirectMessageRequestProcessor<DirectMessage>();
            Expression<Func<DirectMessage, bool>> expression =
                dm =>
                    dm.Type == DirectMessageType.Show &&
                    dm.Count == 1 &&
                    dm.MaxID == 789 &&
                    dm.Page == 1 &&
                    dm.SinceID == 123 &&
                    dm.ID == 456 &&
                    dm.IncludeEntities == true &&
                    dm.SkipStatus == true &&
                    dm.FullText == true;
            var lambdaExpression = expression as LambdaExpression;

            Dictionary<string, string> queryParams = dmReqProc.GetParameters(lambdaExpression);

            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair<string, string>("Type", ((int)DirectMessageType.Show).ToString(CultureInfo.InvariantCulture))));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair<string, string>("Count", "1")));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair<string, string>("MaxID", "789")));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair<string, string>("Page", "1")));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair<string, string>("SinceID", "123")));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair<string, string>("ID", "456")));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair<string, string>("IncludeEntities", "True")));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair<string, string>("SkipStatus", "True")));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair<string, string>("FullText", "True")));
        }
        public void GetParametersTest()
        {
            var dmProc = new DirectMessageRequestProcessor<DirectMessage>();
            var ctx = new TwitterContext();

            var directMessages =
                from tweet in ctx.DirectMessage
                where tweet.Type == DirectMessageType.SentTo
                select tweet;

            var whereFinder = new FirstWhereClauseFinder();
            var whereExpression = whereFinder.GetFirstWhere(directMessages.Expression);
            var lambdaExpression = (LambdaExpression)((UnaryExpression)(whereExpression.Arguments[1])).Operand;
            lambdaExpression = (LambdaExpression)Evaluator.PartialEval(lambdaExpression);

            var queryParams = dmProc.GetParameters(lambdaExpression);

            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair<string, string>("Type", ((int)DirectMessageType.SentTo).ToString())));
        }