public void ReturnCompleteOneLevelPathCamelCaseTest()
        {
            var expected = "franchise.name";
            Expression <Func <Game, object> > predicate = g => g.Franchise.Name;

            Assert.AreEqual(expected, MemberPredicateInterpreter.Run(predicate.Body, camelCaseConfiguration));
        }
        public void ReturnCompleteTwoLevelsPathSnakeCaseTest()
        {
            var expected = "cover.picture.url";
            Expression <Func <Game, object> > predicate = g => g.Cover.Picture.Url;

            Assert.AreEqual(expected, MemberPredicateInterpreter.Run(predicate.Body, snakeCaseConfiguration));
        }
        public void ReturnPropertyNameCamelCaseTest()
        {
            var expected = "name";

            Expression <Func <GameShort, string> > predicate = g => g.Name;

            Assert.AreEqual(expected, MemberPredicateInterpreter.Run(predicate.Body, camelCaseConfiguration));
        }
        public void ReturnMultiplePropertiesSnakeCaseTest()
        {
            var expected = "name,follows";

            Expression <Func <GameShort, object> > predicate = g => new { g.Name, g.Follows };

            Assert.AreEqual(expected, MemberPredicateInterpreter.Run(predicate.Body, snakeCaseConfiguration));
        }
 /// <summary>
 /// Adds one or multiple <em>order by ascending</em> statements to the order by clause of
 /// the API.<br/>
 /// Each call adds a statement to the orders clause<br/>
 /// Prepares the <strong>orders</strong> statement of the Apicalypse query.
 /// </summary>
 /// <param name="predicate">A predicate expression that provides a list of fields or a single fields</param>
 /// <returns>The request builder, to chain the statements</returns>
 public RequestBuilder <T> OrderBy(Expression <Func <T, object> > predicate)
 {
     if (!string.IsNullOrEmpty(orders))
     {
         orders += ",";
     }
     orders += MemberPredicateInterpreter.Run(predicate.Body, configuration);
     return(this);
 }
        /// <summary>
        /// Sets the list of fields to exclude from the API model using the predicate used
        /// in parameters.<br/>
        /// Each call replace the previous.<br/>
        /// Prepares the <strong>excludes</strong> statement of the Apicalypse query.<br/>
        /// Can't be combine with the <em>Select(Expression&lt;Func&lt;T, object&gt;&gt;)</em> or the
        /// <em>Select&lt;TSelect&gt;()</em> methods.
        /// </summary>
        /// <param name="predicate">A predicate expression that provides a list of fields or a single field</param>
        /// <returns>The request builder, to chain the statements</returns>
        public RequestBuilder <T> Exclude(Expression <Func <T, object> > predicate)
        {
            if (selects != "*")
            {
                throw new InvalidOperationException("Can't combine Exclude and Select methods.");
            }

            excludes = MemberPredicateInterpreter.Run(predicate.Body, configuration);

            return(this);
        }
        /// <summary>
        /// Sets the list of fields to gather from the API model with predicate passed
        /// as parameter.<br/>
        /// Each call replace the previous<br/>
        /// Prepares the <strong>fields</strong> statement of the Apicalypse query.
        /// </summary>
        /// <param name="predicate">A predicate expression that provides a list of fields or a single fields</param>
        /// <returns>The request builder, to chain the statements</returns>
        public RequestBuilder <T> Select(Expression <Func <T, object> > predicate)
        {
            if (!string.IsNullOrEmpty(excludes))
            {
                throw new InvalidOperationException("Can't combine Exclude and Select methods.");
            }

            selects = MemberPredicateInterpreter.Run(predicate.Body, configuration);

            return(this);
        }
        public RequestBuilder <T> Search(string search, Expression <Func <T, string> > field)
        {
            if (string.IsNullOrEmpty(search))
            {
                this.search = "";
            }
            else
            {
                this.search = $"{MemberPredicateInterpreter.Run(field.Body, configuration)} {PrepareSearchString(search)}";
            }

            return(this);
        }