title: Moq Event Aggregator Is it possible
body: <p>Wondering if its possible to Moq the Prism EventAggregator
  Let's take the EventAggregator Quickstart they have </p>
  
  <pre><code>     [TestMethod]
        public void PresenterPublishesFundAddedOnViewAddClick()
        {
           var view = new MockAddFundView();
           var EventAggregator = new MockEventAggregator();
           var mockFundAddedEvent = new MockFundAddedEvent();
           EventAggregator.AddMapping&lt;FundAddedEvent&gt;(mockFundAddedEvent);
           var presenter = new AddFundPresenter(EventAggregator);
           presenter.View = view;
           view.Customer = "99";
           view.Fund = "TestFund";
           view.PublishAddClick();
           Assert.IsTrue(mockFundAddedEvent.PublishCalled);
           Assert.AreEqual("99", mockFundAddedEvent.PublishArgumentPayload.CustomerId);
        }       
  
      I have tried to convert the above using moq but I get problems 
  </code></pre>
  
  <p>they have  MockEventAggregator.How can I do that using Moq?</p>
  
  <pre><code>public class MockEventAggregator : IEventAggregator
  {
      Dictionary&lt;Type, object&gt; events = new Dictionary&lt;Type, object&gt;();
      public TEventType GetEvent&lt;TEventType&gt;() where TEventType : EventBase
      {
          return (TEventType)events[typeof(TEventType)];
      }
  
      public void AddMapping&lt;TEventType&gt;(TEventType mockEvent)
      {
          events.Add(typeof(TEventType), mockEvent);
      }
  }
  </code></pre>
  
  <p>Has anybody used MOQ and the EventAggregator are there any examples out there?
  Thanks a lot</p>
  
  <p>EDIT</p>
  
  <p>Following GrameF Answer I have added my code that still does not work.Can you help</p>
  
  <pre><code>            [TestMethod]
              public void PresenterPublishesFundAddedOnViewAddClick2()
              {
  
                  //Arrange
                  var view = new Mock&lt;IAddFundView&gt;();
                  var fakeEventAggregator = new Mock&lt;IEventAggregator&gt;();
                  var fakeMyEvent = new Mock&lt;FundAddedEvent&gt;();
                  fakeEventAggregator.Setup(x =&gt; x.GetEvent&lt;FundAddedEvent&gt;()).Returns(fakeMyEvent.Object); 
  
                  var presenter = new AddFundPresenter(fakeEventAggregator.Object) {View = view.Object};
                  fakeMyEvent.Verify(x =&gt; x.Publish(It.IsAny&lt;FundOrder&gt;())); **//CRASHES** HERE
  
  
  
                  //view.PublishAddClick();
                  //view.Customer = "99";
                  //view.Fund = "TestFund";
  
                  //view.PublishAddClick();
  
                  ////Assert 
                  //Assert.IsTrue(mockFundAddedEvent.PublishCalled);
                  //Assert.AreEqual("99", mockFundAddedEvent.PublishArgumentPayload.CustomerId);
                  //Assert.AreEqual("TestFund", mockFundAddedEvent.PublishArgumentPayload.TickerSymbol);
              }
  </code></pre>