In its simplest form, Bxf acts as a message or request router from application code to a presenter handler.

The idea is that your application code, typically your viewmodel code, needs to do a set of basic things:
  1. Show views
  2. Show status information
  3. Show error information

At runtime these need to be actually displayed to a user. At test time they should not be displayed, but instead the fact that they should have been displayed needs to be recorded, so the unit test can verify that the attempt was made.

To this end, Bxf has two primary interfaces: IShell and IPresenter. And it has a singleton instance of the IShell/IPresenter implementation, accessed through the Bxf.Shell.Instance static property.

Bxf.Shell.Instance exposes the IShell interface by default, so application code can easily call its ShowView, ShowStatus and ShowError methods.

But before the application invokes those methods, you need to create a presenter that actually makes those methods do something useful. The presenter casts Bxf.Shell.Instance to IPresenter and handles three events: OnShowView, OnShowStatus and OnShowError.

A runtime presenter is usually an object that is bound to the main form or main page - basically the main UI shell element - of your application. In the constructor of this presenter object, I have handlers for these three events, and in those handlers is where my code (indirectly or directly) causes the UI shell to display the view, status or error information.

Once the presenter events are being handled, all the rest of the application code can use call the three methods on Bxf.Shell.Instance to show views, status and error information.

In my unit test project I also have a presenter. This is something I typically set up in the test initialization method, again handling the three events. For testing though, I just store the view, region, error, title and status information in private fields so my unit test methods can check those fields to see if the appropriate view, status or error information would have been displayed were the application actually running.

Last edited Jul 26, 2010 at 10:42 PM by RockfordLhotka, version 2


No comments yet.