Mocking Prism views

2 posts, 0 answers
  1. Chuck
    Chuck avatar
    7 posts
    Member since:
    Feb 2012

    Posted 04 Feb 2013 Link to this post

    I posted a support ticket for this, but thought I'd ask in the forum as well. As show below, I attempt to JustMock a Prism view. When this unit test runs, and this line is encountered, I get an exception complaining that cannot locate the corresponding XAML for the view. The stack shows us  in the constructor of the CommandingView class, calling InitializeComponent, which does not sound like mocking. The text of the excpetion is:
    {"The component 'CommandingViewProxy\\+6068b00980684baaaf2f95f50b66a803' does not have a resource identified by the URI '/Infrastructure;component/views/commandingview.xaml'."}

    It seems I should possibly be doing something additional to JustMock a Prism view. Or some other setup is needed.
    Anyone got any suggestions?
    var oCmdView = Mock.Create<CommandingView>();
  2. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 04 Feb 2013 Link to this post

    Hello Chuck,

    Copied from reply in Ticket 655675:
    In order to mock the CommandingView class, you might need to add the "Constructor.Mocked" property as follows:
     
    var oCmdView = Mock.Create<CommandingView>(Constructor.Mocked);


    Greetings,
    Kaloyan
    the Telerik team
    Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.
  3. DevCraft R3 2016 release webinar banner
Back to Top