If you had some interface like so:public interface IExample
{
   event CustomEventHandler Custom;
}

public delegate void CustomEventHandler(object sender, CustomEventArgs e);
public class CustomEventArgs : EventArgs
{
  public bool SomeValue { get; set; }
}

and an object you wanted to test like so:

public class Testable
{
  public Testable(IExample example)
  {
    example.Custom += (o, e) => { e.SomeValue = true; };
  }
}

Then your test might be like so:

IExample e = MockRepository.GenerateMock<IExample>();
IEventRaiser raiser = e.Expect(e.Custom +=
null).IgnoreArguments().GetEventRaiser();

Testable t = new Testable(e);

CustomEventArgs args = new CustomEventArgs();
r.Raise(e, args);
Assert.IsTrue(args.SomeValue);


I hope this helps a little!


On Wed, Nov 26, 2008 at 1:16 PM, Sean <[EMAIL PROTECTED]> wrote:

>
> I was trying to raise a stubbed event that had a custom event argument
> and assert it later, but assertion was failing with complaint that the
> custom event argument is expected, but what received is EventArgs. All
> of the samples I have seen so far for Raise extension method were
> always passing EventArgs.
> Could someone point out where I am mistaken or give a hint where to
> look?
>
> Thank you,
> Sean
> >
>


-- 
Justin Chase
http://www.justnbusiness.com

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to