Claudio Lassala
unread,Dec 22, 2008, 3:04:54 PM12/22/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Rhino.Mocks
Hi all,
first and foremost, I'm new to Rhino Mocks, so bear with me
there... :)
I have a UserControl class in a WPF app that looks sort of like this:
public class SelectorDisplayView : UserControl
{
public bool Active { get; set; }
protected void SelectorDisplayView_MouseUp(object sender,
MouseButtonEventArgs e)
{
this.Active = true;
}
}
I'm trying to write a test to make sure the Active property gets set
whenever the control has been clicked. I thought I could use Rhino's
EventRaiser to raise the MouseUp event and test my code, so I wrote
the test like so:
[TestMethod]
public void
Active_property_should_be_set_to_true_when_view_has_been_clicked()
{
var mockRepository = new MockRepository();
m_View = mockRepository.PartialMock<SelectorDisplayView>
();
m_View.MouseUp += delegate { };
var mouseUpRaiser = LastCall.IgnoreArguments
().GetEventRaiser();
mockRepository.ReplayAll();
bool eventWasRaised = false;
m_View.ActiveChanged += (sender, e) => eventWasRaised =
true;
mouseUpRaiser.Raise(m_View, EventArgs.Empty);
Assert.IsTrue(eventWasRaised);
mockRepository.VerifyAll();
}
The test fails with the following error:
System.InvalidOperationException: Invalid call, the last call has been
used or no call has been made (make sure that you are calling a
virtual (C#) / Overridable (VB) method).
I'm not sure what I'm doing wrong here... any clue?