ShellContext is untestable

1 view
Skip to first unread message

Bil Simser

unread,
Apr 30, 2008, 10:03:10 AM4/30/08
to xeva
Dave,

I found in trying to test ShellContext (which is inherited from
ApplicationContext) that the automocker blows up. If I do this:

[SetUp]
protected override void Before_each_spec()
{
_shellContext = Create<ShellContext>();
}

I get a weird error on the tear down of a test (something to do with a
handle destroyed). There's something in the ApplicationContext class
that causes it pain and suffering. I know ShellContext is only in the
sample app, but what do you think of this:

* add a field called _applicationContext of type ApplicationContext in
ShellContext
* create a method called AssociateWith(ApplicationContext
applicationContext) to set it
* make ShellContext implement IDisposable and dispose of the
ApplicationContext member
* make the following changes in Program.cs:

ApplicationContext context = new ApplicationContext();
shellContext.AssociateWith(context);
Application.Run(applicationContext);

This would make ShellContext testable so you could construct it
without an application context (since it's really only needed for the
call to Application.Run()) and doesn't need inherit the class.

David Laribee

unread,
Apr 30, 2008, 10:18:48 AM4/30/08
to xe...@googlegroups.com
Will look at this tonight. Maybe it'd be good to create an ApplicationController abstraction.
--


/ Dave

http://thebeelog.com
Reply all
Reply to author
Forward
0 new messages