Mocking Sitefinity

2 posts, 0 answers
  1. Erik
    Erik avatar
    13 posts
    Member since:
    May 2011

    Posted 17 May 2012 Link to this post

    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?
  2. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 23 May 2012 Link to this post

    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 >>

  3. DevCraft R3 2016 release webinar banner
Back to Top