public void ShouldGetExpectedExpressionFromConstValue(object value, string expectedExpression)
        {
            IValueLambdaProvider constLambda = new ConstValueLambdaProvider(typeof(SourceClass), value);
            var lambda = constLambda.GetLambda();

            lambda.ToString().Should().Be(expectedExpression);
        }
        public void ShouldThrowExceptionWhenValueCanNotConvertToTargetType(object value, Type targetType)
        {
            IValueLambdaProvider constLambda = new ConstValueLambdaProvider(typeof(SourceClass), value);
            Action action = () => constLambda.GetLambda(targetType);

            action.Should().Throw <QueryExpressionException>()
            .WithMessage($"convert value * to target type '{targetType.FullName}' error.");
        }
        public void ShouldGetExpectedExpressionWhenValueAsEnumType(object value, Type targetType,
                                                                   string expectedExpression)
        {
            IValueLambdaProvider constLambda = new ConstValueLambdaProvider(typeof(SourceClass), value);
            var lambda = constLambda.GetLambda(targetType);

            lambda.ReturnType.Should().Be(targetType);
            lambda.ToString().Should().Be(expectedExpression);
        }
        public void ShouldGetExpectedExpressionWhenValueAsDateTimeOffsetType(object value, Type targetType,
                                                                             long timeStamp)
        {
            IValueLambdaProvider constLambda = new ConstValueLambdaProvider(typeof(SourceClass), value);
            var lambda = constLambda.GetLambda(targetType);

            var datetimeOffset = lambda.Compile().DynamicInvoke(new object[] { null });

            datetimeOffset.Should().BeOfType <DateTimeOffset>()
            .Which.ToUnixTimeMilliseconds().Should().Be(timeStamp);
        }
        public void ShouldGetExpectedExpressionWhenValueAsDateTimeType(object value, Type targetType,
                                                                       string expectedExpression)
        {
            IValueLambdaProvider constLambda = new ConstValueLambdaProvider(typeof(SourceClass), value);
            var lambda   = constLambda.GetLambda(targetType);
            var datetime = lambda.Compile().DynamicInvoke(new object[] { null });

            datetime.Should().BeOfType <DateTime>()
            .Which.ToString("yyyy-MM-dd HH:mm:ss.fff").Should().Be(expectedExpression)
            ;
        }