private static void EvaluateEquality(SelectedMemberInfo memberInfo, IEquivalencyValidationContext context, IEquivalencyAssertionOptions config)
        {
            var memberMatch = FindMatchFor(memberInfo, context, config);

            memberMatch.Should().NotBeNull($"{context.Expectation.GetType().Name} should have a matching member for {memberInfo.Name}");

            var subjectProperty = memberInfo.GetValue(context.Subject, new object[0]);

            var expectedProperty = memberMatch.GetValue(context.Expectation, new object[0]);

            subjectProperty.ShouldBeEquivalentTo(expectedProperty, options => options.Using(new ExcludeOneOfAsMembersSelectionRule()), context.Because, context.BecauseArgs);
        }
        private static string GetPropertyValueTextFor(object value, SelectedMemberInfo selectedMemberInfo, FormattingContext context, FormatChild formatChild)
        {
            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(context.Depth + 1),
                                 selectedMemberInfo.Name,
                                 formatChild(selectedMemberInfo.Name, propertyValue)));
        }
Exemple #3
0
        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)));
        }