This is a migrated thread and some comments may be shown as answers.

JustMock + Compact Framework?

3 Answers 73 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joe Parks
Top achievements
Rank 1
Joe Parks asked on 22 Feb 2011, 12:02 AM
Is it possible to use JustMock for Compact Framework projects in VS 2008? For now, I am using the free edition.
The following does not compile, where "IService" is just an example interface with a single method, "DoSomething()":

            IService service =  Mock.Create<IService>();
                
Mock.Arrange(()=>service.DoSomething()).MustBeCalled();

The compiler spits out this error:
Error 2 Cannot convert lambda expression to type 'System.Linq.Expressions.Expression`1<Telerik.JustMock.Action2>' because it is not a delegate type

3 Answers, 1 is accepted

Sort by
0
Ricky
Telerik team
answered on 23 Feb 2011, 01:29 PM
Hi Joe,

Thanks again for raising the question.

It turns out that compact framework fails to auto convert TDelegate to Expression<TDelegate> format.

Officially, we don’t have a compact framework build for JustMock. However, the recommended the way is to reference the target compact framework library right from .net 3.5 project and things will work out just nicely. Additionally, you will be able to use TestDriven.Net or similar test runners without much tweaking.

Finally, I have attached a sample project that shows the similar technique. Please check it out and do write us back for further issues.


Kind regards,
Ricky
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Joe Parks
Top achievements
Rank 1
answered on 23 Feb 2011, 06:07 PM
Hrm. The project does compile, but the test does not run on the device. It throws the exception:

System.MissingMethodException: File or assembly name 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089', or one of its dependencies, was not found..

It sounds like, for device unit tests, I'll need to stick with Rhino Mocks. It's a shame, because JustMock seems like an overall better library.
0
Ricky
Telerik team
answered on 24 Feb 2011, 04:06 PM
Hi Joe,

Thanks again for the reply.

Actually, within the .net CF runtime most mocking framework that uses expression and invokes member from Reflection.Emit won’t work (Ex.Moq). Here is one interesting post from StackOverflow on this that describes it nicely.

http://stackoverflow.com/questions/1004560/rhino-mocks-compact-framework

Unless you are testing your library within the device itself, the other way is to create a .net 3.5 project  and then reference the compact framework library from there. In that case, you are executing the tests using .net 3.5 runtime therefore won’t face the above issues.

Hope this information is useful.

Best wishes,
Ricky
the Telerik team

Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
General Discussions
Asked by
Joe Parks
Top achievements
Rank 1
Answers by
Ricky
Telerik team
Joe Parks
Top achievements
Rank 1
Share this question
or