示例#1
0
 private bool ArgumentsMatchesArgumentConstraints(ArgumentCollection argumentCollection)
 {
     return(argumentCollection
            .AsEnumerable()
            .Zip(this.argumentConstraints, (x, y) => new { ArgumentValue = x, Constraint = y })
            .All(x => x.Constraint.IsValid(x.ArgumentValue)));
 }
示例#2
0
        private bool ArgumentsMatchesArgumentValidators(ArgumentCollection argumentCollection)
        {
            foreach (var argumentValidatorPair in argumentCollection.AsEnumerable().Zip(this.argumentValidators))
            {
                if (!argumentValidatorPair.Second.IsValid(argumentValidatorPair.First))
                {
                    return(false);
                }
            }

            return(true);
        }
示例#3
0
        public void Arguments_from_the_call_should_be_sent_to_the_argument_predicate()
        {
            var fake = A.Fake <IFoo>();
            ArgumentCollection arguments = null;

            ThisCall.To(fake).WhenArgumentsMatch(x => { arguments = x; return(true); }).Throws(new ApplicationException());
            fake.Baz(null, null);

            try
            {
                fake.Baz(1, "a");
            }
            catch (ApplicationException) { }

            Assert.That(arguments.AsEnumerable().ToArray(), Has.Some.EqualTo(1).And.Some.EqualTo("a"));
        }
示例#4
0
        public void UsePredicateToValidateArguments_should_configure_matcher_to_pass_arguments_to_the_specified_predicate()
        {
            this.StubMethodInfoManagerToReturn(true);
            ArgumentCollection argumentsPassedToPredicate = null;

            var matcher = this.CreateMatcher <IFoo>(x => x.Bar(null, null));

            matcher.UsePredicateToValidateArguments(x =>
            {
                argumentsPassedToPredicate = x;
                return(true);
            });

            var call = ExpressionHelper.CreateFakeCall <IFoo>(x => x.Bar(1, 2));

            matcher.Matches(call);

            Assert.That(argumentsPassedToPredicate.AsEnumerable(), Is.EquivalentTo(new object[] { 1, 2 }));
        }
 private bool ArgumentsMatchesArgumentConstraints(ArgumentCollection argumentCollection)
 {
     return argumentCollection
         .AsEnumerable()
         .Zip(this.argumentConstraints, (x, y) => new { ArgumentValue = x, Constraint = y })
         .All(x => x.Constraint.IsValid(x.ArgumentValue));
 }
        private bool ArgumentsMatchesArgumentConstraints(ArgumentCollection argumentCollection)
        {
            foreach (var argumentConstraintPair in argumentCollection.AsEnumerable().Zip(this.argumentConstraints))
            {
                if (!argumentConstraintPair.Item2.IsValid(argumentConstraintPair.Item1))
                {
                    return false;
                }
            }

            return true;
        }