I have an interfac, IEntityMonitor, which defines, amongst other
things, a number of events.
I mock it and set it up as follows, and pass the mock to another
class.
The class does nothing to the mock.
However, when I run the code, I get the following error:
*** IEntityMonitor.add_DataCleared(System.EventHandler); Expected #1,
Actual #0. ***
Question: Why is the additinal, 'magical' expectation being set up?
Question : How do I remove the expectation?
My Code, below...
public void After_LoadData_Channels_Must_Contain_Valid_Data()
{
ObservableCollection<ChannelPresentationModel> result =
null;
IEntityImageCache entityImageCache;
IEntityMonitor entityMonitorMock;
using (mockRepository.Record())
{
// Arrange
IPacSystem system = new PACObjectModel.SystemClass();
IPacSession session = new
PACObjectModel.SessionClass();
SessionManager.Login(string.Empty, "installer",
string.Empty, out system, out session);
entityMonitorMock =
this.mockRepository.StrictMock<IEntityMonitor>();
entityMonitorMock.ChannelsChanged += null;
LastCall.Constraints(Is.NotNull());
entityImageCache = new EntityImageCache(session,
entityMonitorMock);
ChannelsStub channelsStub = new ChannelsStub();
SetupResult.For(entityMonitorMock.GetChannels(-1)).Return(channelsStub);
}
//Act
mockRepository.Playback();
HardwareTreePresentationModel
hardwareTreePresentationModel = new HardwareTreePresentationModel(-1,
null, null, entityImageCache, entityMonitorMock);
hardwareTreePresentationModel.LoadDataCommand.Execute(null);
result =
hardwareTreePresentationModel.ChannelPresentationModels;
// Assert
Assert.IsNotNull(result, "The
HardwareTreePresentationModel.Channels property is null.");
Assert.IsTrue(result.Count > 0, "The
hardwareTreePresentationModel.Channels count is not greater than
zero!");
//TODO : work out way to .VerifyAll() (DataCleared
expected!)
mockRepository.VerifyAll();
}
//***************** INTERFACE CODE *******************************
public interface IEntityMonitor
{
event EventHandler AcknowledgeAllEnabledChanged;
event EntityMonitor.AlarmAreaHandler AlarmAreaChanged;
event EntityMonitor.AlarmAreaHandler AlarmAreaEvent;
event EntityMonitor.AlarmHandler AlarmEvent;
event EventHandler AlarmPointAlarm;
event EntityMonitor.AlarmPointHandler AlarmPointChanged;
event EntityMonitor.AlarmPointHandler AlarmPointEvent;
event EntityMonitor.AlarmPointStatusChangeHandler
AlarmPointStatusChange;
event EntityMonitor.ChannelsChangedHandler ChannelsChanged;
event EventHandler DataCleared;
event DataRefreshHandler DataRefresh;
}
etc.
--
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.