예제 #1
0
        private string[] TryToMatch <T>(object subject, T expectation, int expectationIndex)
        {
            using var scope = new AssertionScope();
            parent.AssertEqualityUsing(context.CreateForCollectionItem(expectationIndex.ToString(), subject, expectation));

            return(scope.Discard());
        }
        public bool Handle(IEquivalencyValidationContext context, IEquivalencyValidator parent,
                           IEquivalencyAssertionOptions config)
        {
            Array expectationAsArray = (Array)context.Expectation;

            if (AreComparable(context, expectationAsArray))
            {
                Digit digit = BuildDigitsRepresentingAllIndices(expectationAsArray);

                do
                {
                    object subject       = ((Array)context.Subject).GetValue(digit.Indices);
                    string listOfIndices = string.Join(",", digit.Indices);
                    object expectation   = expectationAsArray.GetValue(digit.Indices);
                    IEquivalencyValidationContext itemContext = context.CreateForCollectionItem(
                        listOfIndices,
                        subject,
                        expectation);

                    parent.AssertEqualityUsing(itemContext);
                }while (digit.Increment());
            }

            return(true);
        }
        public bool Handle(IEquivalencyValidationContext context, IEquivalencyValidator parent,
            IEquivalencyAssertionOptions config)
        {
            Array subjectAsArray = (Array) context.Subject;

            if (AreComparable(context, subjectAsArray))
            {
                Digit digit = BuildDigitsRepresentingAllIndices(subjectAsArray);

                do
                {
                    var expectation = ((Array) context.Expectation).GetValue(digit.Indices);
                    IEquivalencyValidationContext itemContext = context.CreateForCollectionItem(
                        string.Join(",", digit.Indices),
                        subjectAsArray.GetValue(digit.Indices),
                        expectation);

                    parent.AssertEqualityUsing(itemContext);
                }
                while (digit.Increment());
            }

            return true;
        }