Hello,
I can mock successfully an Interface when it contains only properties and methods; but when adding an event declaration it causes an error.
Code of the class that is tested:
Public Class EcranControleur
Implements IEcran
Private WithEvents monAfficheur As IEcran
Public Sub New(ByVal afficheur As IEcran)
monAfficheur = afficheur ' => CAUSES ERROR BECAUSE OF THE "WithEvents"
[...]
End Sub
End Class
The error details in NUnit-gui gives me :
at TypeMock.Mock.a(String A_0, Object[] A_1, Object A_2, Object A_3, Int32 A_4)
at ao.a(String A_0, Object[] A_1, Object A_2, Object A_3)
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Object[] A_4)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Object p1)
at MockIEcran.add_DébutCréationGrille(DébutCréationGrilleEventHandler )
at Stepware.Sudoku.Logique.EcranControleur.set_monAfficheur(IEcran WithEventsValue)
at Stepware.Sudoku.Logique.EcranControleur..ctor(IEcran afficheur) in D:DevSudoku2IHMEcranControleur.vb:line 11
at Stepware.Sudoku.Logique.EcranControleurTest.DébutTest() in D:DevSudoku2IHMEcranControleurTest.vb:line 26
--TearDown
[...]
The issue seems to be an unexpected call to "MockIEcran.add_DébutCréationGrille" when it tries to add a reference to an event handler.
How can I do?
Thanks a lot.