Testing View Models in Bxf

Testing View Models in Bxf

Old forum URL: forums.lhotka.net/forums/t/10984.aspx


simon_may posted on Wednesday, December 14, 2011

I have recently moved on to using Csla 4.1 and am in the process of learning to use XAML, MVVM etc. The "Using CSLA 4 WPF and Silverlight" ebook is most useful in helping me tackle the learning curve.

However, I am struggling when it comes to understanding the way to test view Models in the Bxf framework. In the section "Implementing a Mock Shell" it concludes with the line "With this MockShell class ready for use, all the remains is to tell Bxf to use it, and to handle the three Bxf events" but I can find no reference to how to tell Bxf to use it.

I thought that the samples might give me a clue, so I looked that th Project Tracker project which has the test descrived in the ebook, but to no avail. I stepped though the test and  found that the real Shell is used with the real View Factory, rather than the mocks.

I may well be being exstremely thick here, but can someone point me in the right direction. How should I best tell the Bxf framework to use the mock Shell?

Regards

Simon

RockfordLhotka replied on Wednesday, December 14, 2011

Bxf questions should be posted in the http://bxf.codeplex.com discussion forum.

The short answer is that your test initialization method needs to set Shell.Instance to an instance of the mock shell.

simon_may replied on Monday, December 19, 2011

Please accept my apologies Rocky for posting in the wrong forum. As I suspected I was being very dense. thnk you for the pointer.

JonM replied on Wednesday, January 18, 2012

Simon,

Did you ever figure this out?  I've got the CSLA MVVM video series (which rocks by the way) but I really need some help figuring out how to unit test my BXF view models.  I post a question in the BXF forum last friday but havn't gotten a response.  If anyone has some simple sample code of a SL/MVVM project with unit test code that would be greatly appreciated here.

Copyright (c) Marimer LLC