Пример #1
0
        public IPropertySetterAnyValueConfiguration <TValue> CallsToSet <TValue>(Expression <Func <TFake, TValue> > propertySpecification)
        {
            Guard.AgainstNull(propertySpecification, nameof(propertySpecification));

            var parsedCallExpression = this.expressionParser.Parse(propertySpecification, this.manager.Object);

            this.GuardAgainstWrongFake(parsedCallExpression.CallTarget);
            this.AssertThatMemberCanBeIntercepted(parsedCallExpression);

            var parsedSetterCallExpression = PropertyExpressionHelper.BuildSetterFromGetter <TValue>(parsedCallExpression);

            return(new PropertySetterConfiguration <TValue>(
                       parsedSetterCallExpression,
                       this.CreateVoidArgumentValidationConfiguration));
        }
        public IPropertySetterAnyValueConfiguration <TValue> CallToSet <TValue>(Expression <Func <TValue> > propertySpecification)
        {
            Guard.AgainstNull(propertySpecification, nameof(propertySpecification));
            var parsedCallExpression = this.callExpressionParser.Parse(propertySpecification);

            GuardAgainstNonFake(parsedCallExpression.CallTarget);
            this.AssertThatMemberCanBeIntercepted(parsedCallExpression);

            var fake = Fake.GetFakeManager(parsedCallExpression.CallTarget);
            var parsedSetterCallExpression = PropertyExpressionHelper.BuildSetterFromGetter <TValue>(parsedCallExpression);

            return(new PropertySetterConfiguration <TValue>(
                       parsedSetterCallExpression,
                       newParsedSetterCallExpression =>
                       this.CreateVoidArgumentValidationConfiguration(fake, newParsedSetterCallExpression)));
        }