internal static void ConfigureAssertionRules <TActual>(
     EquivalencyAssertionOptions <TActual> actualOptions,
     IEquivalencyAssertionOptions subConfigOptions)
 {
     //Reverse order because Using prepends
     foreach (var assertionRule in subConfigOptions.AssertionRules.Reverse())
     {
         actualOptions.Using(new CollectionMemberAssertionRuleDecorator(assertionRule));
     }
 }
 private static void ConfigureAssertionRules <TActual>(
     EquivalencyAssertionOptions <TActual> actualOptions,
     IEquivalencyAssertionOptions subConfigOptions)
 {
     // Reverse order because Using prepends
     foreach (var equivalencyStep in subConfigOptions.UserEquivalencySteps.Reverse())
     {
         actualOptions.Using(new CollectionMemberAssertionRuleDecorator(equivalencyStep));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Includes all properties of <typeparamref name="T"/> when comparing the subject with another object using <see cref="EqualTo(object)"/>,
        /// except those specified using a property expression.
        /// </summary>
        /// <param name="propertyExpression">A single property expression to exclude.</param>
        /// <param name="propertyExpressions">Optional list of additional property expressions to exclude.</param>
        public PropertyAssertions <T> AllPropertiesBut(Expression <Func <T, object> > propertyExpression,
                                                       params Expression <Func <T, object> >[] propertyExpressions)
        {
            config.Using(new AllDeclaredPublicPropertiesSelectionRule());

            foreach (var expression in propertyExpressions.Concat(new[] { propertyExpression }))
            {
                config.Excluding(expression);
            }

            return(this);
        }
        internal static void ConfigureMatchingRules <TActual>(
            EquivalencyAssertionOptions <TActual> actualOptions,
            IEquivalencyAssertionOptions subConfigOptions)
        {
            if (subConfigOptions.MatchingRules.Any())
            {
                actualOptions.WithoutMatchingRules();
            }

            //Reverse order because Using prepends
            foreach (var matchingRule in subConfigOptions.MatchingRules.Reverse())
            {
                actualOptions.Using(new CollectionMemberMatchingRuleDecorator(matchingRule));
            }
        }
        private static void ConfigureSelectionRules <TActual>(
            EquivalencyAssertionOptions <TActual> actualOptions,
            IEquivalencyAssertionOptions subConfigOptions)
        {
            var opts = subConfigOptions;

            if (opts.SelectionRules.Any())
            {
                actualOptions.WithoutSelectionRules();
            }

            foreach (var selectionRule in opts.SelectionRules)
            {
                actualOptions.Using(new CollectionMemberSelectionRuleDecorator(selectionRule));
            }
        }
        internal static void ConfigureSelectionRules <TActual>(
            EquivalencyAssertionOptions <TActual> actualOptions,
            IEquivalencyAssertionOptions subConfigOptions)
        {
            var opts = subConfigOptions;

            if (opts.SelectionRules.Any())
            {
                actualOptions.WithoutSelectionRules();
            }

            //Reverse order because Using prepends
            foreach (var selectionRule in opts.SelectionRules.Reverse())
            {
                actualOptions.Using(new CollectionMemberSelectionRuleDecorator(selectionRule));
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Allows overriding the way structural equality is applied to particular properties.
 /// </summary>
 /// <param name="predicate">
 /// A predicate based on the <see cref="ISubjectInfo"/> of the subject that is used to identify the property for which the
 /// override applies.
 /// </param>
 public EquivalencyAssertionOptions <TSubject> When(Expression <Func <ISubjectInfo, bool> > predicate)
 {
     options.Using(new AssertionRule <TProperty>(predicate, action));
     return(options);
 }