Пример #1
0
        public SelectedMemberInfo Match(SelectedMemberInfo subjectMember, object expectation, string memberPath, IEquivalencyAssertionOptions config)
        {
            SelectedMemberInfo compareeSelectedMemberInfoInfo = null;

            if (config.IncludeProperties)
            {
                compareeSelectedMemberInfoInfo = SelectedMemberInfo.Create(expectation.GetType()
                                                                           .FindProperty(subjectMember.Name, subjectMember.MemberType));
            }

            if ((compareeSelectedMemberInfoInfo == null) && config.IncludeFields)
            {
                compareeSelectedMemberInfoInfo = SelectedMemberInfo.Create(expectation.GetType()
                                                                           .FindField(subjectMember.Name, subjectMember.MemberType));
            }

            if ((compareeSelectedMemberInfoInfo == null) && ExpectationImplementsMemberExplicitly(expectation, subjectMember))
            {
                compareeSelectedMemberInfoInfo = subjectMember;
            }

            if (compareeSelectedMemberInfoInfo == null)
            {
                string path = (memberPath.Length > 0) ? memberPath + "." : "member ";

                Execute.Assertion.FailWith(
                    "Subject has " + path + subjectMember.Name + " that the other object does not have.");
            }

            return(compareeSelectedMemberInfoInfo);
        }
Пример #2
0
        public SelectedMemberInfo Match(SelectedMemberInfo subjectMember, object expectation, string memberPath,
                                        IEquivalencyAssertionOptions config)
        {
            var propertySelectedMemberInfo = subjectMember as PropertySelectedMemberInfo;

            if (propertySelectedMemberInfo != null)
            {
                return
                    (SelectedMemberInfo.Create(obsoleteMatchingRule.Match(propertySelectedMemberInfo.PropertyInfo,
                                                                          expectation, memberPath)));
            }

            return(null);
        }