示例#1
0
        public static void AllPropertiesAreNotDefault(object obj, Func <PropertyInfo, bool> customHandler = null)
        {
            if (customHandler == null)
            {
                customHandler = p => false;
            }

            foreach (var prop in obj.GetType().GetProperties())
            {
                if (!customHandler(prop))
                {
                    Assert.IsFalse(TestReflectionHelpers.IsDefaultValue(prop, obj), $"Property '{prop.Name}' did not have a value.");
                }
            }
        }
示例#2
0
        public static void AllPropertiesAndFieldsAreNotDefault(object obj, Func <MemberInfo, bool> customHandler = null)
        {
            if (customHandler == null)
            {
                customHandler = p => false;
            }

            foreach (var prop in obj.GetType().GetProperties(flags).Where(p => !p.GetIndexParameters().Any()))
            {
                if (!customHandler(prop))
                {
                    Assert.IsFalse(TestReflectionHelpers.IsDefaultValue(prop, obj), $"Property '{prop.Name}' did not have a value.");
                }
            }

            foreach (var field in obj.GetType().GetFields(flags))
            {
                if (!customHandler(field))
                {
                    Assert.IsFalse(TestReflectionHelpers.IsDefaultValue(field, obj), $"Property '{field.Name}' did not have a value.");
                }
            }
        }