internal static IEquivalencyValidationContext CreateForNestedMember(
            this IEquivalencyValidationContext equivalencyValidationContext,
            SelectedMemberInfo nestedMember,
            SelectedMemberInfo matchingProperty)
        {
            object subject     = nestedMember.GetValue(equivalencyValidationContext.Subject, null);
            object expectation = matchingProperty.GetValue(equivalencyValidationContext.Expectation, null);

            return(CreateNested(
                       equivalencyValidationContext,
                       nestedMember,
                       subject,
                       expectation,
                       "member ",
                       nestedMember.Name,
                       ".",
                       nestedMember.MemberType));
        }
Пример #2
0
        internal static IEquivalencyValidationContext CreateForNestedMember(this IEquivalencyValidationContext context,
                                                                            SelectedMemberInfo nestedMember, SelectedMemberInfo matchingProperty)
        {
            string memberDescription = nestedMember.Name;
            string propertyPath      = (context.SelectedMemberDescription.Length == 0) ? "member " : context.SelectedMemberDescription + ".";

            return(new EquivalencyValidationContext
            {
                SelectedMemberInfo = nestedMember,
                Subject = nestedMember.GetValue(context.Subject, null),
                Expectation = matchingProperty.GetValue(context.Expectation, null),
                SelectedMemberPath = context.SelectedMemberPath.Combine(memberDescription, "."),
                SelectedMemberDescription = propertyPath + memberDescription,
                Because = context.Because,
                BecauseArgs = context.BecauseArgs,
                CompileTimeType = nestedMember.MemberType,
                RootIsCollection = context.RootIsCollection
            });
        }
        private static string GetPropertyValueTextFor(object value, SelectedMemberInfo selectedMemberInfo, int nextMemberNestingLevel,
            IList<object> processedObjects)
        {
            object propertyValue;

            try
            {
                propertyValue = selectedMemberInfo.GetValue(value, null);
            }
            catch (Exception ex)
            {
                propertyValue = string.Format("[Member '{0}' threw an exception: '{1}']", selectedMemberInfo.Name, ex.Message);
            }

            return string.Format("{0}{1} = {2}",
                CreateWhitespaceForLevel(nextMemberNestingLevel),
                selectedMemberInfo.Name,
                Formatter.ToString(propertyValue, false, processedObjects, nextMemberNestingLevel));
        }