コード例 #1
0
        public void GivenNewExpressionWhenSerializedThenShouldDeserialize(
            ConstructorInfo info,
            Expression[] args,
            MemberInfo[] members)
        {
            var ctor = CtorSerializerTests.MakeNew(info, args, members);
            var json = Serializer.Serialize(ctor);

            Reset();

            rulesConfig.Value.RuleForConstructor(selector => selector.ByMemberInfo(info));
            var target = Serializer.Deserialize <NewExpression>(json);

            if (info.DeclaringType.IsAnonymousType())
            {
                Assert.Equal(typeof(AnonInitializer), target.Type);
            }
            else
            {
                Assert.True(ctor.IsEquivalentTo(target));
            }
        }