Example #1
0
        public void PropertyLambdaCanReadAPropertyNameFromALambda()
        {
            IPropertyInterface obj = null;
            var lambda             = PropertyLambda <IPropertyInterface> .Create(() => obj.GetSet);

            lambda.Getter.Name.ShouldBe("get_GetSet");
        }
Example #2
0
        /// <summary>
        /// Execute `onGet` when the property specified in `propertyLookupExpression` is called. For example,
        /// call `<code>fake.StubGetter(() => fake.Object.MyProperty, () => 5)</code>` to always return five.
        /// </summary>
        /// <param name="propertyLookupExpression">Pass a lambda of the following form: <code>() => fake.Object.MyProperty</code>.</param>
        /// <param name="onGet">Pass a lambda of the following form: <code>() => "hello"</code>.</param>
        public FuncCallHistory <TProp> StubGetter <TProp>(Expression <Func <TProp> > propertyLookupExpression, Func <TProp> onGet)
        {
            var lambda = PropertyLambda <TObj> .Create(propertyLookupExpression);

            var stubbedOperation = new FuncCallHistory <TProp>();

            interceptor.RegisterOperation(lambda.Getter, onGet, stubbedOperation);
            return(stubbedOperation);
        }