private void CompareIgnoreOrder(IList actual, IList expected, EntityListComparisonResult comparisonResult)
        {
            var overallSuccess = true;

            for (var i = 0; i < expected.Count; i++)
            {
                var expectedItem = expected[i];
                var found        = false;
                for (var j = 0; j < actual.Count; j++)
                {
                    var actualItem         = actual[i];
                    var entityMatcher      = new EntityMatchingStrategy(parentContext.WithIndex(i));
                    var entityMatchResults = entityMatcher.Compare(actualItem, expectedItem, expectedItem.GetType());
                    var success            = entityMatchResults.All(x => x.Success);
                    //comparisonResult.EntityMatchResults.Add(new EntityMatchResult
                    //{
                    //    Success = success,
                    //    MemberResults = entityMatchResults
                    //});
                    found |= success;
                    if (found)
                    {
                        break;
                    }
                }
                overallSuccess &= found;
            }
            comparisonResult.Equal = overallSuccess;
        }
Exemple #2
0
        protected override List <MatchResult> InternalValidate(PropertyInfo actualProperty, object actualObj,
                                                               object expectedObj,
                                                               ParentContext parentContext = null)
        {
            var actualChild   = GetPropertyValue(actualProperty, actualObj);
            var expectedChild = GetPropertyValue(GetExpectedProperty(expectedObj, actualProperty), expectedObj);
            var matcher       = new EntityMatchingStrategy(parentContext);

            return(matcher.Compare(actualChild, expectedChild));
        }
        private void CompareStrictOrder(IList actual, IList expected, EntityListComparisonResult comparisonResult)
        {
            var overallSuccess = true;

            for (var i = 0; i < expected.Count; i++)
            {
                var    expectedItem = expected[i];
                object actualItem   = null;
                if (i < actual.Count)
                {
                    actualItem = actual[i];
                }
                var entityMatcher      = new EntityMatchingStrategy(parentContext.WithIndex(i));
                var entityMatchResults = entityMatcher.Compare(actualItem, expectedItem, expectedItem.GetType());
                var success            = entityMatchResults.All(x => x.Success);
                comparisonResult.EntityMatchResults.Add(new EntityMatchResult
                {
                    Success       = success,
                    MemberResults = entityMatchResults
                });
                overallSuccess &= success;
            }
            comparisonResult.Equal = overallSuccess;
        }