Exemple #1
0
        public void ConstantExpressionShouldSerialize(ConstantExpression constant)
        {
            var target = serializer.Serialize(constant, TestSerializer.State);

            if (target.Value is Constant constantValue)
            {
                Assert.True(evaluator.ValuesAreEquivalent(
                                ((ConstantExpression)constant.Value).Value,
                                constantValue.Value));
            }
            else if (constant.Value is MemberInfo member)
            {
                Assert.Contains(member.Name, (string)target.Value);
            }
            else if (constant.Type.IsAnonymousType())
            {
                Assert.IsType <AnonType>(target.Value);
            }
            else
            {
                Assert.True(evaluator.ValuesAreEquivalent(constant.Value, target.Value));
            }
        }