public void StringToUpperEqual()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.ProductName.ToUpper() == "CHAI";

            Assert.Equal("toupper(ProductName) eq 'CHAI'", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void EqualDateTimeOffset()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.Updated == new DateTimeOffset(new DateTime(2013, 1, 1, 0, 0, 0, DateTimeKind.Utc));

            Assert.Equal($"Updated eq {FormatSettings.GetDateTimeOffsetFormat("2013-01-01T00:00:00Z")}", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void LengthOfStringEqual()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.ProductName.Length == 4;

            Assert.Equal("length(ProductName) eq 4", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void ModEqualNumeric()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.ProductID % 1 == 2;

            Assert.Equal("ProductID mod 1 eq 2", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void EqualDecimalWithFractionalPart()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.Price == 1.23M;

            Assert.Equal($"Price eq 1.23{FormatSettings.DecimalNumberSuffix}", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void EqualFieldToString()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.ProductName.ToString() == "Chai";

            Assert.Equal("ProductName eq 'Chai'", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void GreaterOrEqualNumeric()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.ProductID >= 1.5;

            Assert.Equal($"ProductID ge 1.5{FormatSettings.DoubleNumberSuffix}", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void MonthEqual()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.CreationTime.Month == 2;

            Assert.Equal("month(CreationTime) eq 2", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void YearEqual()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.CreationTime.Year == 3;

            Assert.Equal("year(CreationTime) eq 3", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void ConcatEqual()
        {
            Expression <Func <TestEntity, bool> > filter = x => string.Concat(x.ProductName, "Chai") == "ChaiChai";

            Assert.Equal("concat(ProductName,'Chai') eq 'ChaiChai'", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void DayEqual()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.CreationTime.Day == 1;

            Assert.Equal("day(CreationTime) eq 1", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void ReplaceStringEqual()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.ProductName.Replace("a", "o") == "Choi";

            Assert.Equal("replace(ProductName,'a','o') eq 'Choi'", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void SubstringWithPositionAndLengthEqual()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.ProductName.Substring(1, 2) == "ha";

            Assert.Equal("substring(ProductName,1,2) eq 'ha'", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void IndexOfStringEqual()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.ProductName.IndexOf("ai") == 1;

            Assert.Equal("indexof(ProductName,'ai') eq 1", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
 public void ExpressionBuilderGeneric()
 {
     var filter = new ODataExpression<TestEntity>(x => x.ProductName == "Chai");
     filter = filter || new ODataExpression<TestEntity>(x => x.ProductID == 1);
     Assert.Equal("ProductName eq 'Chai' or ProductID eq 1", filter.AsString(_session));
 }
        public void HourEqual()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.CreationTime.Hour == 4;

            Assert.Equal("hour(CreationTime) eq 4", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void Precedence()
        {
            Expression <Func <TestEntity, bool> > filter = x => (x.ProductID == 1 || x.ProductID == 2) && x.ProductName == "Chai";

            Assert.Equal("(ProductID eq 1 or ProductID eq 2) and ProductName eq 'Chai'", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void MinuteEqual()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.CreationTime.Minute == 5;

            Assert.Equal("minute(CreationTime) eq 5", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void GreaterNumeric()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.ProductID > 1;

            Assert.Equal("ProductID gt 1", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void SecondEqual()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.CreationTime.Second == 6;

            Assert.Equal("second(CreationTime) eq 6", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void LessOrEqualNumeric()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.ProductID <= 1;

            Assert.Equal("ProductID le 1", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void FloorEqual()
        {
            Expression <Func <TestEntity, bool> > filter = x => decimal.Floor(x.Price) == 1;

            Assert.Equal(string.Format("floor(Price) eq 1{0}", FormatSettings.DecimalNumberSuffix), ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void EqualLong()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.ProductID == 1L;

            Assert.Equal($"ProductID eq 1{FormatSettings.LongNumberSuffix}", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void CeilingEqual()
        {
            Expression <Func <TestEntity, bool> > filter = x => decimal.Ceiling(x.Price) == 2;

            Assert.Equal(string.Format("ceiling(Price) eq 2{0}", FormatSettings.DecimalNumberSuffix), ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void EqualGuid()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.LinkID == Guid.Empty;

            Assert.Equal($"LinkID eq {FormatSettings.GetGuidFormat("00000000-0000-0000-0000-000000000000")}", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void EqualNestedProperty()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.Nested.ProductID == 1;

            Assert.Equal("Nested/ProductID eq 1", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void EqualTimeSpan()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.Period == new TimeSpan(1, 2, 3);

            Assert.Equal($"Period eq {FormatSettings.TimeSpanPrefix}'PT1H2M3S'", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void Or()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.ProductName == "Chai" || x.ProductID == 1;

            Assert.Equal("ProductName eq 'Chai' or ProductID eq 1", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void StringToLowerEqual()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.ProductName.ToLower() == "chai";

            Assert.Equal("tolower(ProductName) eq 'chai'", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void Not()
        {
            Expression <Func <TestEntity, bool> > filter = x => !(x.ProductName == "Chai");

            Assert.Equal("not (ProductName eq 'Chai')", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
        public void StringEndsWithEqual()
        {
            Expression <Func <TestEntity, bool> > filter = x => x.ProductName.EndsWith("Ch") == true;

            Assert.Equal("endswith(ProductName,'Ch') eq true", ODataExpression.FromLinqExpression(filter).AsString(_session));
        }
 public void ExpressionBuilder()
 {
     Expression<Predicate<TestEntity>> condition1 = x => x.ProductName == "Chai";
     Expression<Func<TestEntity, bool>> condition2 = x => x.ProductID == 1;
     var filter = new ODataExpression(condition1);
     filter = filter || new ODataExpression(condition2);
     Assert.Equal("ProductName eq 'Chai' or ProductID eq 1", filter.AsString(_session));
 }