public void TimeSpanFromDays()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <double, TimeSpan>(queryConverter, i => TimeSpan.FromDays(i));

            expr.ShouldBeEquivalentTo(
                ExpressionUtils.CreateFunctionTerm <int, int>(queryConverter, i => (i * 86400)));
        }
        public void TimeSpanTicksConstructor()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <long, TimeSpan>(queryConverter, i => new TimeSpan(i));

            expr.ShouldBeEquivalentTo(
                ExpressionUtils.CreateFunctionTerm <long, long>(queryConverter, i => i / TimeSpan.TicksPerSecond));
        }
        public void TimeSpanDaysHoursMinutesSecondsMillisecondsConstructor()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <int, TimeSpan>(queryConverter, i => new TimeSpan(i, i, i, i, i));

            expr.ShouldBeEquivalentTo(
                ExpressionUtils.CreateFunctionTerm <int, int>(queryConverter, i => (i * 86400) + (i * 3600) + (i * 60) + i + (i / 1000)));
        }
        public void TimeSpanFromTicks()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <long, TimeSpan>(queryConverter, i => TimeSpan.FromTicks(i));

            expr.ShouldBeEquivalentTo(
                ExpressionUtils.CreateFunctionTerm <long, long>(queryConverter, i => (i / TimeSpan.TicksPerSecond)));
        }
Beispiel #5
0
        private void DoDirectCastWithTypeConstraintDoubleParameter <T>() where T : ITestInterface
        {
            var expr = ExpressionUtils.CreateFunctionTerm <T, T, double>(
                queryConverter,
                (o1, o2) => ((ITestInterface)o1).SomeNumber);

            AssertFunctionIsGetFieldSomeNumberDoubleParameter(expr);
        }
Beispiel #6
0
        private void DoIndirectCastByTypeConstraintSingleParameter <T>() where T : ITestInterface
        {
            var expr = ExpressionUtils.CreateFunctionTerm <T, double>(
                queryConverter,
                o => o.SomeNumber);

            AssertFunctionIsGetFieldSomeNumberSingleParameter(expr);
        }
Beispiel #7
0
        public void DirectIntentionalCastToExactSameTypeDoubleParameter()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <TestObject, TestObject, double>(
                queryConverter,
                (o1, o2) => ((ITestInterface)o1).SomeNumber);

            AssertFunctionIsGetFieldSomeNumberDoubleParameter(expr);
        }
        public void DateTimeYear()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTime, int>(queryConverter, dt => dt.Year);

            AssertDateTimeAccessor(expr, Term.TermType.YEAR);
        }
        public void DateTimeOffsetAddTicks()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTimeOffset, DateTimeOffset>(queryConverter, dt => dt.AddTicks(1));

            AssertAddFunctionWithConversion(expr, 1, 1.0 / TimeSpan.TicksPerSecond);
        }
        public void DateTimeAddSeconds()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTime, DateTime>(queryConverter, dt => dt.AddSeconds(123));

            AssertAddFunctionWithConversion(expr, 123, (double)TimeSpan.TicksPerSecond / TimeSpan.TicksPerSecond);
        }
Beispiel #11
0
        private void DoIndirectCastByTypeConstraintDoubleParameter <T>() where T : ITestInterface
        {
            var expr = ExpressionUtils.CreateFunctionTerm <T, T, double>(datumConverterFactory, (o1, o2) => o1.SomeNumber);

            AssertFunctionIsGetFieldSomeNumberDoubleParameter(expr);
        }
        public void DateTimeOffsetDayOfYear()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTimeOffset, int>(queryConverter, dt => dt.DayOfYear);

            AssertDateTimeAccessor(expr, Term.TermType.DAY_OF_YEAR);
        }
        public void DateTimeOffsetSecond()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTimeOffset, int>(queryConverter, dt => dt.Second);

            AssertDateTimeAccessor(expr, Term.TermType.SECONDS);
        }
        public void DateTimeOffsetHour()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTimeOffset, int>(queryConverter, dt => dt.Hour);

            AssertDateTimeAccessor(expr, Term.TermType.HOURS);
        }
        public void DateTimeOffsetAddSeconds()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTimeOffset, DateTimeOffset>(datumConverterFactory, dt => dt.AddSeconds(123));

            AssertAddFunctionWithConversion(expr, 123, (double)TimeSpan.TicksPerSecond / TimeSpan.TicksPerSecond);
        }
        public void DateTimeAddTicks()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTime, DateTime>(datumConverterFactory, dt => dt.AddTicks(1));

            AssertAddFunctionWithConversion(expr, 1, 1.0 / TimeSpan.TicksPerSecond);
        }
        public void DateTimeAddMinutes()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTime, DateTime>(datumConverterFactory, dt => dt.AddMinutes(23));

            AssertAddFunctionWithConversion(expr, 23, (double)TimeSpan.TicksPerMinute / TimeSpan.TicksPerSecond);
        }
        public void DateTimeAddTimeSpan()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTime, DateTime>(datumConverterFactory, dt => dt.Add(TimeSpan.FromSeconds(51)));

            AssertAddFunction(expr, TimeSpan.FromSeconds(51));
        }
        public void DateTimeOffsetPlusTimeSpan()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTimeOffset, DateTimeOffset>(datumConverterFactory, dt => dt + TimeSpan.FromSeconds(50));

            AssertAddFunction(expr, TimeSpan.FromSeconds(50));
        }
        public void DateTimeDay()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTime, int>(queryConverter, dt => dt.Day);

            AssertDateTimeAccessor(expr, Term.TermType.DAY);
        }
Beispiel #21
0
        public void DirectIntentionalCastToExactSameTypeSingleParameter()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <TestObject, double>(datumConverterFactory, o => ((ITestInterface)o).SomeNumber);

            AssertFunctionIsGetFieldSomeNumberSingleParameter(expr);
        }
        public void DateTimeOffsetMonth()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTimeOffset, int>(queryConverter, dt => dt.Month);

            AssertDateTimeAccessor(expr, Term.TermType.MONTH);
        }
        public void DateTimePlusTimeSpan()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTime, DateTime>(queryConverter, dt => dt + TimeSpan.FromSeconds(50));

            AssertAddFunction(expr, TimeSpan.FromSeconds(50));
        }
        public void DateTimeOffsetMinute()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTimeOffset, int>(queryConverter, dt => dt.Minute);

            AssertDateTimeAccessor(expr, Term.TermType.MINUTES);
        }
        public void DateTimeOffsetAddTimeSpan()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTimeOffset, DateTimeOffset>(queryConverter, dt => dt.Add(TimeSpan.FromSeconds(51)));

            AssertAddFunction(expr, TimeSpan.FromSeconds(51));
        }
        public void DateTimeOffsetDayOfWeek()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTimeOffset, DayOfWeek>(queryConverter, dt => dt.DayOfWeek);

            AssertDateTimeAccessor(expr, Term.TermType.DAY_OF_WEEK);
        }
        public void DateTimeOffsetAddMinutes()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <DateTimeOffset, DateTimeOffset>(queryConverter, dt => dt.AddMinutes(23));

            AssertAddFunctionWithConversion(expr, 23, (double)TimeSpan.TicksPerMinute / TimeSpan.TicksPerSecond);
        }
        public void DateTimeYearMonthDayConstructor()
        {
            var expr = ExpressionUtils.CreateFunctionTerm <int, DateTime>(queryConverter, (i) => new DateTime(i, i, i));
            var variableRefenceTerm = new Term()
            {
                type = Term.TermType.VAR,
                args =
                {
                    new Term()
                    {
                        type  = Term.TermType.DATUM,
                        datum = new Datum()
                        {
                            type  = Datum.DatumType.R_NUM,
                            r_num = 2,
                        }
                    }
                }
            };

            expr.ShouldBeEquivalentTo(
                new Term()
            {
                type = Term.TermType.FUNC,
                args =
                {
                    new Term()
                    {
                        type = Term.TermType.MAKE_ARRAY,
                        args =
                        {
                            new Term()
                            {
                                type  = Term.TermType.DATUM,
                                datum = new Datum()
                                {
                                    type  = Datum.DatumType.R_NUM,
                                    r_num = 2,
                                }
                            }
                        }
                    },
                    new Term()
                    {
                        type = Term.TermType.TIME,
                        args =
                        {
                            variableRefenceTerm,
                            variableRefenceTerm,
                            variableRefenceTerm,
                            new Term()
                            {
                                type  = Term.TermType.DATUM,
                                datum = new Datum()
                                {
                                    type  = Datum.DatumType.R_STR,
                                    r_str = "Z",
                                }
                            }
                        }
                    }
                }
            }
                );
        }
Beispiel #29
0
        private void DoDirectCastWithTypeConstraintSingleParameter <T>() where T : ITestInterface
        {
            var expr = ExpressionUtils.CreateFunctionTerm <T, double>(datumConverterFactory, o => ((ITestInterface)o).SomeNumber);

            AssertFunctionIsGetFieldSomeNumberSingleParameter(expr);
        }