/// <summary>
///A test for OnViewReady ()
///</summary>
[TestMethod()]
public void OnViewReadyTest()
{
MockRepository repo = new MockRepository();
//the mocked general web service
IGeneralWS genWS = repo.StrictMock<IGeneralWS>();
//the mocked view
IHelloWorldView view = repo.StrictMock<IHelloWorldView>();
Support.TestableRootWorkItem workitem = new Support.TestableRootWorkItem();
//this will be used to simulate the call back from the web service
Rhino.Mocks.Interfaces.IEventRaiser pingCompletedRaiser;
using (repo.Record())
{
Expect
.Call(delegate { view.ShowMessage("Loading..."); });
//Expect that the PingAsynch() method will be called
Expect
.Call(delegate { genWS.PingAsync(); });
//Provide the entry point for the call back.
genWS.PingCompleted += null;
pingCompletedRaiser = LastCall
.IgnoreArguments()
.GetEventRaiser();
Expect
.Call(delegate { view.ShowMessage("Pong"); });
}
HelloWorldViewPresenter target = new HelloWorldViewPresenter(genWS);
target.View = view;
target.WorkItem = workitem;
using (repo.Playback())
{
target.OnViewReady();
//This "new EventArgs" would be impossible without the second partial class
PingCompletedEventArgs args = new PingCompletedEventArgs("Pong");
//make the callback call....
pingCompletedRaiser.Raise(genWS, args);
//we're done!
}
}