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

Mocking Prism views

1 Answer 15 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chuck
Top achievements
Rank 1
Chuck asked on 04 Feb 2013, 02:51 PM
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>();

1 Answer, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 04 Feb 2013, 04:16 PM
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.
Tags
General Discussions
Asked by
Chuck
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Share this question
or