Re: [TFUI] Dialogs and EventHandlers

Owen Rogers <[email protected]> Tue, 8 Nov 2005 08:26:51 -0800
Newsgroups gmane.comp.programming.test-first-user-interfaces
Message-ID <[email protected]>
hi tim,

On 07/11/05, Tim Haughton <[email protected]> wrote:
> The model class would look something like...
>
> MyCollaborator
> {
>     public virtual Font GetFontFromUserSelection( Font defaultFont )
>     {
>          FontDialog fd = new FontDialog();
>          _GetFontFromUserSelection( fd, defaultFont );
>     }
>
>     public virtual DialogueResult _GetFontFromUserSelection(
>          FontDialogue fd, Font defaultFont )
>     {
>          fd.Font = defaultFont;
>          if(fd.ShowDialog( Parent ) != DialogResult.Cancel )
>          {
>               return Fdialog.Font;
>          }
>
>          return defaultFont;
>     }
> }

what would the tests look like for your collaborator?  are
FontDialogue and FontDialog the same class?  how would we mock out
methods on FontDialog which has got nonvirtual methods?

> The event handler in the form would look like....
>
> private void menuItem15_Click(object sender, System.EventArgs e)
> {
>  rtbDisplay.Font = new mc.GetFontFromUserSelection(rtbDisplay.Font);
> }

is the "new" keyword here a type-o, or am i missing something?

> We can test _GetFontFromUserSelection by passing in mocks for the
> FontDialogue and the Font (using the dynamic mock I posted earlier
> today?) to make sure that's working OK.

do we really want to expose this method (_GetFontFromUserSelection)? 
are there other ways that we might be able to mock out this dependency
rather than creating a new convention for methods that are exposed
just for testing?

cheers,
owen.
--
Owen Rogers | http://dotnetjunkies.com/weblog/exortech |
CruiseControl.NET - http://ccnet.thoughtworks.com


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~-> 

To unsubscribe, email:
TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/TestFirstUserInterfaces/

<*> To unsubscribe from this group, send an email to:
    TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/