public void When_invoked_then_method_is_called()
 {
     var vm = new MockViewModelWithAction();
     var invoker = new ExpressionInvoker<string>(p => vm.Action(p));
     invoker.Invoke("Foo");
     Assert.IsTrue(vm.ActionCalled);
 }
Exemplo n.º 2
0
        public static IMappingExpression <TSource, TDestination> FromSourceProperty <TSource, TDestination>(
            this IMappingExpression <TSource, TDestination> expression,
            Expression <Func <TSource, object> > propertyExpression)
        {
            IExpressionInvoker invoker = new ExpressionInvoker();

            foreach (var property in Mapper.GetAllTypeMaps()
                     .First(x => x.SourceType == typeof(TSource) && x.DestinationType == typeof(TDestination))
                     .GetUnmappedPropertyNames())
            {
                expression.ForMember(property, opt => opt.ResolveUsing(src => invoker.InvokeFunctionExpression(propertyExpression, src, property)));
            }
            return(expression);
        }