chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Try to run this test, it seems that TypeMock is not able to see the event defined in IView.


using System;
using MbUnit.Framework;
using TypeMock;

namespace EventBugTypeMock
{
   [TestFixture]
   public class PresenterTest
   {
      [TearDown]
      public void TearDown()
      {
         MockManager.Verify();
      }
      [Test]
      public void EventBugTest()
      {
         IViewDerived mockView = (IViewDerived) RecorderManager.CreateMockedObject(typeof(IViewDerived));
         MockedEvent okEvent;
         using (RecordExpectations recorder = RecorderManager.StartRecording())
         {
            mockView.Ok += null;
            okEvent = RecorderManager.LastMockedEvent;
         }   
         Presenter presenter = new Presenter(mockView);
         okEvent.Fire(this, EventArgs.Empty);
      }
   }
   
   public interface IView
   {
      event EventHandler Ok;
   }
   
   public interface IViewDerived : IView
   {
   }
   
   public class Presenter
   {
      IViewDerived m_view;

      public Presenter(IViewDerived view)
      {
         m_view = view;
         m_view.Ok += new EventHandler(m_view_Ok); 
      }

      private void m_view_Ok(object sender, EventArgs e)
      {

      }
   }
}
asked by acarpe (1.7k points)

5 Answers

0 votes
This seems to be a bug :twisted:
Thanks for reporting this.
We will fix it and send you a patch offline.
answered by scott (32k points)
0 votes
Hi
I sent you the patch.
Please tell me it solves your problem.
answered by ohad (35.4k points)
0 votes
I've received it but it does not solve the problem yet.

Thanks,
Antonio.
answered by acarpe (1.7k points)
0 votes
Hi Antonio
Please check if you don't have 2 TypeMock.dll in the GAC.
If its true uninstall them and install the correct version.
answered by ohad (35.4k points)
0 votes
I had only one TypeMock in GAC but after a
gacutil.exe /i "C:Program FilesTypeMockTypeMock.NETTypeMock.dll"
it worked!
Thank you
Antonio.
answered by acarpe (1.7k points)
...