Hi! Help me, please.
When I try to use RhinoMock 3.5 I have problem with tests like this:
public void Test()
{
bool doIt = true;
var view = MockRepository.GenerateStub<IView>();
view.Stub(x => x.DoWork()).WhenCalled(i => { doIt =
false; });
//view.Stub(x => x.DoWork()).WhenCalled(i => Thread.Sleep
(100));
view.Stub(x => x.Init()).WhenCalled(i =>
{
view.Raise(x
=> x.OnStart += null, this, EventArgs.Empty);
while (doIt)
Thread.Sleep(50);
});
var presenter = new Presenter(view);
presenter.Start();
}
This test fall in endless loop when I use BackgroundWorker in
implementation Presenter class:
public class Presenter
{
private readonly IView view;
private BackgroundWorker worker = new BackgroundWorker();
public Presenter(IView view)
{
this.view = view;
this.view.OnStart += new EventHandler(view_OnStart);
this.worker.DoWork += new DoWorkEventHandler
(WorkerDoWork);
}
void view_OnStart(object sender, EventArgs e)
{
this.worker.RunWorkerAsync(this.view);
}
public void Start()
{
this.view.Init();
}
private void WorkerDoWork(object sender, DoWorkEventArgs e)
{
var v = e.Argument as IView;
v.DoWork();
}
}
If, for example, i change in method view_OnStart the line
this.worker.RunWorkerAsync(this.view)
on line
this.view.DoWork();
for suppress to invoke BackgroundWorker - test work fine.
In early versions of RhinoMock test like this work fine too.
Thnx/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/RhinoMocks?hl=en
-~----------~----~----~----~------~----~------~--~---