コード例 #1
0
        public void ObjectAttributeDefinedTest()
        {
            var objectWithAttr    = new NormalWithAttrClass();
            var objectWithoutAttr = new NormalWithoutAttrClass();

            Types.IsAttributeDefined <NormalWithAttrClass, ModelOneAttribute>(objectWithAttr).ShouldBeTrue();
            Types.IsAttributeDefined <NormalWithAttrClass, ModelTwoAttribute>(objectWithAttr).ShouldBeFalse();

            Types.IsAttributeDefined <NormalWithoutAttrClass, ModelOneAttribute>(objectWithoutAttr).ShouldBeFalse();
            Types.IsAttributeDefined <NormalWithoutAttrClass, ModelTwoAttribute>(objectWithoutAttr).ShouldBeFalse();

            objectWithAttr    = null;
            objectWithoutAttr = null;

            Types.IsAttributeDefined <NormalWithAttrClass, ModelOneAttribute>(objectWithAttr).ShouldBeFalse();
            Types.IsAttributeDefined <NormalWithAttrClass, ModelTwoAttribute>(objectWithAttr).ShouldBeFalse();

            Types.IsAttributeDefined <NormalWithoutAttrClass, ModelOneAttribute>(objectWithoutAttr).ShouldBeFalse();
            Types.IsAttributeDefined <NormalWithoutAttrClass, ModelTwoAttribute>(objectWithoutAttr).ShouldBeFalse();

            Types.IsAttributeDefined <NormalWithAttrClass, ModelOneAttribute>(objectWithAttr, isOptions: TypeIsOptions.IgnoreNullable).ShouldBeTrue();
            Types.IsAttributeDefined <NormalWithAttrClass, ModelTwoAttribute>(objectWithAttr, isOptions: TypeIsOptions.IgnoreNullable).ShouldBeFalse();

            Types.IsAttributeDefined <NormalWithoutAttrClass, ModelOneAttribute>(objectWithoutAttr, isOptions: TypeIsOptions.IgnoreNullable).ShouldBeFalse();
            Types.IsAttributeDefined <NormalWithoutAttrClass, ModelTwoAttribute>(objectWithoutAttr, isOptions: TypeIsOptions.IgnoreNullable).ShouldBeFalse();
        }
コード例 #2
0
        public void ExpressionCopierTest()
        {
            var original = new NormalWithAttrClass {
                Good = "Nice", Index = 99, Nice = "Good"
            };
            var target = TypeVisit.DeepCopy(original, DeepCopyOptions.ExpressionCopier);

            Assert.Same(original, original);
            Assert.Same(target, target);
            Assert.NotSame(original, target);
        }