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

Mocking Sitefinity

1 Answer 186 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 1
Erik asked on 17 May 2012, 09:59 PM
The reason I got JustMock was so that I could unit test my custom code for a Sitefinity 5 project. I needed it because the methods for interfacing with Sitefinity make prolific use of static classes. I am, however, unable to mock some things in Sitefinity. Here are some examples involving the PageManager:

When I try to do this (so that I can arrange PageManager.GetManager()):
Mock.SetupStatic(typeof(PageManager), StaticConstructor.NonMocked);

I get this: 
GenericArguments[1], 'TItem', on 'Telerik.Sitefinity.Data.GetQuery`2[TProvider,TItem]' violates the constraint of type parameter 'TItem'.

When I try to do this:
var pageManager = Mock.Create<PageManager>(Constructor.Mocked);

I get this: 
GenericArguments[0], 'Telerik.Sitefinity.GenericContent.Model.ILocatable', on 'Void Intercept[TItem](TItem, Boolean, Telerik.Sitefinity.Modules.GenericContent.ContentManagerBase`1[Telerik.Sitefinity.Modules.Pages.PageDataProvider], Boolean ByRef)' violates the constraint of type 'TItem'.

The eventual goal is for me to mock the call "GetPageNode" on the PageManager. Unfortunately, an interface containing that call is not provided on the PageManager.

Any ideas?

1 Answer, 1 is accepted

Sort by
0
Ricky
Telerik team
answered on 23 May 2012, 04:58 PM
Hi Erik,

Thanks again for reporting the issue and sorry for the late reply.

We are able to reproduce the problem and should you need a fix urgently please open a support ticket where I will send you the latest build.


Kind Regards
Mehfuz
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
General Discussions
Asked by
Erik
Top achievements
Rank 1
Answers by
Ricky
Telerik team
Share this question
or