Support primitive return types in setup

New method which allows specifying the return type to support the above

Updated Moq version to 4.2
Ok, I'll take a look.


On Mon, Jun 23, 2014 at 4:57 PM, Tim Kellogg <notifications@github.com>
wrote:

> In Moq.AutoMock/AutoMocker.cs:
>
> > @@ -171,6 +171,21 @@ public ISetup<TService> Setup<TService>(Expression<Action<TService>> setup)
> >              return Setup<ISetup<TService>, TService>(m => m.Setup(setup));
> >          }
> >
> > +        /// <summary>
> > +        /// Shortcut for mock.Setup(...), creating the mock when necessary.
> > +        /// For specific return types. E.g. primitive, structs
> > +        /// that cannot be infered
> > +        /// </summary>
> > +        /// <typeparam name="TService"></typeparam>
> > +        /// <typeparam name="TReturn"></typeparam>
> > +        /// <param name="setup"></param>
> > +        /// <returns></returns>
> > +        public ISetup<TService, TReturn> Setup<TService, TReturn>(Expression<Func<TService, TReturn>> setup)
> > +            where TService : class
> > +        {
> > +            return Setup<ISetup<TService, TReturn>, TService>(m => m.Setup(setup));
>
> constraining TReturn to struct would make it more obvious what it's
> useful for. But I'm talking about runtime checks for the regular
> Setup<TService> method so that if someone is using Setup<TService> to
> return an int or long it gives them a friendly nudge toward this overload.
>
> --
> Reply to this email directly or view it on GitHub
> <https://github.com/tkellogg/Moq.AutoMocker/pull/9/files#r14082656>.
>



-- 

Ian Cox
C.T.O.

Release  Mobile

m:            Matrix Studios, 91 Peterborough Road, London, SW6 3BU
w:            http://www.releasemobile.com

Registered in England.  Number 06323661