/// <summary>
        /// Gets a detailled equality comparison result.
        /// </summary>
        /// <returns>The equality result.</returns>
        /// <param name="x">The first object.</param>
        /// <param name="y">The second object.</param>
        public EqualityResult GetEqualityResult(TParent x, TParent y)
        {
            try
            {
                var valueX = valueProvider.GetValue(x);
                var valueY = valueProvider.GetValue(y);

                return(valueRule.GetEqualityResult(valueX, valueY));
            }
            catch (Exception e)
            {
                var ruleResult = new EqualityRuleResult(Name, false, exception: e);
                return(resultFactory.GetEqualityResult(new[] { ruleResult }));
            }
        }
示例#2
0
        /// <summary>
        /// Gets a detailled equality comparison result.
        /// </summary>
        /// <returns>The equality result.</returns>
        /// <param name="x">The first object.</param>
        /// <param name="y">The second object.</param>
        public EqualityResult GetEqualityResult(T x, T y)
        {
            var wrappedResult = wrapped.GetEqualityResult(x, y);

            if (wrappedResult == null)
            {
                return(null);
            }

            var results = wrappedResult.RuleResults
                          .Select(res => new EqualityRuleResult(nameTransformer(res.Name), res.Passed, res.ValueA, res.ValueB, res.Exception))
                          .ToArray();

            return(resultFactory.GetEqualityResult(results));
        }