var urlHelper = Mock.Create<
UrlHelper
>( Constructor.Mocked );
Mock.Arrange( () => urlHelper.Action( Arg.IsAny<
string
>(), Arg.IsAny<
string
>() ) )
.DoInstead( ( string actionName, string controllerName ) => {} )
.Returns( ( string actionName, string controllerName ) => String.Format( "/{0}/{1}", controllerName, actionName ) );
The error is:
Error 4 The type arguments for method 'Telerik.JustMock.Helpers.MultipleReturnValueChainHelper.Returns<TReturn>(Telerik.JustMock.Expectations.Abstraction.IAssertable, TReturn)' cannot be inferred from the usage. Try specifying the type arguments explicitly. D:\DevL\Overview\Alpha\Source\Test\Client\Client.Test\Core\Menus\MenuBuilderTest.cs 29 11 Client.Test
Second...what do I have to do to get it to compile? I've tried specifying the template parameters for Returns and casting the lambda to Func2<string,string,string>. I'm not sure why it's complaining.
Thanks,
Chris
7 Answers, 1 is accepted
Thank you for sending the issue.
The reason for the exception is that UrlHelper.Action(string, string) has overload with System.Web.Routing.RouteValueDictionary and if you are testing in .net 4.0 please make sure that you reference the corrrect System.Web.Routing dll that is referenced by UrlHelper. I found using decompiler that the version pointed by .net 4.0 client framework does not have RouteValueDictionary at all. Once i referenced the correct version, the build is green.
I am attaching my test project to let you have a look and hope that solves your issue.
Kind Regards,
Mehfuz
the Telerik team

Now, when calling, urlHelper.Action, I'm getting a validation exception (Operation could destabilize the runtime). It's happening on a call to GenerateUrl inside the original UrlHelper implementation.
Why is that even being called? Doesn't the .DoInstead replace the original implementation with (in my case) nothing?
I am using .NET 4 and MVC 3.
Thanks,
Chris
Thanks again for your reply. I was having the exception in GenerateUrl when my profiler is not turned on. May be you could check if you have the profiler installed and enabled (visual studio addin is installed and enable JustMock is selected).
Hope that solves your issue.
Kind Regards,
Mehfuz
the Telerik team

I submitted a support ticket so that I could upload a test project.
Chris
An answer to this issue has been posted in the other support ticket that you have sent. Please take a look into it.
Sorry for any inconvenience caused and hope to hear from you soon.
Kind Regards,
Ricky
the Telerik team

Chris
The issue is occurring because of the conflict between the .net 4.0 System.Web and the one that is loaded in the AppDomain for intercepting by JustMock profiler (.net 3.5). We are still working on this and it will take some time to resolve this.
However the test is working perfectly fine with MVC 2 assemblies and calls made in MVC 3 that does not include the arguments referencing members from System.Web 4.0 as well.
Kind Regards,
Mehfuz
the Telerik team