The Arg<> generic takes a type that represents your event signature. So for your example, the following should work:
service.AssertWasCalled(s => s.GetCarriersCompleted += Arg<EventHandler<GetCarriersCompletedEventArgs>>.Is.Anything); --- Patrick Steele http://weblogs.asp.net/psteele On Wed, Dec 8, 2010 at 11:38 AM, Bill44077 <[email protected]> wrote: > Hi, > I've been struggling for awhile now trying to figure out how to verify > that an event gets attached to a mock. In the documentation is this: > > Event registration > > mock.Load += OnLoad; > mock.AssertWasCalled(x => x.Load += Arg<LoadEvent>.Is.Anything); > > I can't seem to figure out what some of these things are, like the > Arg<LoadEvent>. My code attached an event like this in the Search > object: > > public void GetCarrierList() > { > try > { > _dataService.GetCarriersCompleted += new > EventHandler<GetCarriersCompletedEventArgs>(OnCarrierDataReturned); > _dataService.GetCarriersAsync(_param); > > } > catch (Exception ex) > { > > } > } > > the IDataService interface has this: > > public interface IDataService : IMACSWcfService > { > void > GetCarriersAsync(System.Collections.Generic.Dictionary<string, string> > param); > event System.EventHandler<GetCarriersCompletedEventArgs> > GetCarriersCompleted; > } > > I am trying to write a test something like this: > > [TestMethod] > public void > Search_GetCarrierList_Should_WireUp_GetCarriersCompleted() > { > IDataService dataSvc = > MockRepository.GenerateStub<IDataService>(); > Search srch = new Search(dataSvc, vr); > srch.GetCarrierList(); > dataSvc.GetCarriersCompleted += > srch.OnCarrierDataReturned; > dataSvc.AssertWasCalled(x => x.GetCarriersCompleted += > Arg<GetCarriersCompletedEventArgs>.Is.Anything); > > } > > I've also tried: > > dataSvc.AssertWasCalled(x => x.GetCarriersCompleted += > Arg.Is.Anything); > > It doesn't seem to know what "Anything" is. > I would have thought this would be simple (and I'm sure that as soon > as someone can point out what I'm doing wrong that it will be). But > for now I'm confused. Please help. > > thanks, > Bill44077 > > -- > 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. > > -- 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.
