コード例 #1
0
        public void Apply_does_not_invoke_action_when_value_null()
        {
            var actionInvoked = false;
            var convention    = new PropertyConventionWithHaving <object>(
                Enumerable.Empty <Func <PropertyInfo, bool> >(),
                p => null,
                (c, v) => actionInvoked = true);
            var propertyInfo  = new MockPropertyInfo();
            var configuration = new Configuration.Properties.Primitive.PrimitivePropertyConfiguration();

            convention.Apply(propertyInfo, () => configuration, new ModelConfiguration());

            Assert.False(actionInvoked);
        }
コード例 #2
0
        public void Apply_does_not_invoke_action_when_value_null()
        {
            var actionInvoked = false;
            var convention = new PropertyConventionWithHaving<object>(
                Enumerable.Empty<Func<PropertyInfo, bool>>(),
                p => null,
                (c, v) => actionInvoked = true);
            var propertyInfo = new MockPropertyInfo();
            var configuration = new Configuration.Properties.Primitive.PrimitivePropertyConfiguration();

            convention.Apply(propertyInfo, () => configuration, new ModelConfiguration());

            Assert.False(actionInvoked);
        }
コード例 #3
0
        public void Apply_invokes_action_with_value_when_not_null()
        {
            var    actionInvoked = false;
            object capturedValue = null;
            var    value         = new object();
            var    convention    = new PropertyConventionWithHaving <object>(
                Enumerable.Empty <Func <PropertyInfo, bool> >(),
                p => value,
                (c, v) =>
            {
                actionInvoked = true;
                capturedValue = v;
            });
            var propertyInfo  = new MockPropertyInfo();
            var configuration = new Configuration.Properties.Primitive.PrimitivePropertyConfiguration();

            convention.Apply(propertyInfo, () => configuration, new ModelConfiguration());

            Assert.True(actionInvoked);
            Assert.Same(value, capturedValue);
        }
コード例 #4
0
        public void Apply_invokes_action_with_value_when_not_null()
        {
            var actionInvoked = false;
            object capturedValue = null;
            var value = new object();
            var convention = new PropertyConventionWithHaving<object>(
                Enumerable.Empty<Func<PropertyInfo, bool>>(),
                p => value,
                (c, v) =>
                {
                    actionInvoked = true;
                    capturedValue = v;
                });
            var propertyInfo = new MockPropertyInfo();
            var configuration = new Configuration.Properties.Primitive.PrimitivePropertyConfiguration();

            convention.Apply(propertyInfo, () => configuration, new ModelConfiguration());

            Assert.True(actionInvoked);
            Assert.Same(value, capturedValue);
        }