コード例 #1
0
        private IList <IArgumentSpecification> GetGetterCallSpecificationsFromSetterCall(ICall callToSetter)
        {
            var lastSetterArg     = callToSetter.GetOriginalArguments().Last();
            var lastSetterArgType = callToSetter.GetParameterInfos().Last().ParameterType;

            var argumentSpecifications = callToSetter.GetArgumentSpecifications();

            if (argumentSpecifications.Count == 0)
            {
                return(argumentSpecifications);
            }

            // Getter call has one less argument than the setter call (the last arg is trimmed).
            // Therefore, we need to remove the last argument specification if it's for the trimmed arg.
            // Otherwise, NSubstitute might find that the redundant argument specification is present and the
            // validation logic might trigger an exception.
            if (_argSpecCompatTester.IsSpecificationCompatible(argumentSpecifications.Last(), lastSetterArg, lastSetterArgType))
            {
                argumentSpecifications = SkipLast(argumentSpecifications);
            }

            return(argumentSpecifications);
        }
コード例 #2
0
 public bool AnyFor(object?argument, Type argumentType)
 {
     return(AllSpecifications.Any(x => _argSpecCompatibilityTester.IsSpecificationCompatible(x, argument, argumentType)));
 }