|
From: Jim A. <JA...@th...> - 2004-12-08 16:35:18
|
<FONT face=3D"Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size= =3D2><DIV>I think VB.Net is a red herring. I think the real problem i= s the ByRef modifier on IFileCollection::Add. When you tried it with = C#, did you add the same (ref) modifier?</DIV><DIV> </DIV><DIV>The ByR= ef problem has been fixed but not rolled into any release - you just n= eed to download the latest snapshot from CVS on SourceForge.</DIV><DIV>&nbs= p;</DIV><DIV>Jim</DIV><DIV> </DIV><DIV>ThoughtWorks<BR></DIV><FONT col= or=3D#990099>-----nmo...@li... wrote: -----<BR= ><BR></FONT><blockquote style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MAR= GIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">To: nmock= -ge...@li...<BR>From: "Chris Bartlett" <chris=5Fbartle= tt...@ho...><BR>Sent by: nmo...@li...<BR= >Date: 12/08/2004 03:41PM<BR>Subject: [Nmock-general] ExecutionEngineExcept= ion with overloaded methods in VB.NET<BR><BR><FONT face=3Dmonospace size=3D= 2>When ever I use NMock with overloaded methods in VB.NET I receive an <BR>= ExecutionEngineException exception.<BR><BR>I have created a simple project = to demonstrate the problem using a <BR>collection.<BR><BR><BR>Interfaces:<B= R><BR>Public Interface IFile<BR><BR> ReadOnly Property FileName() As S= tring<BR><BR>End Interface<BR><BR><BR>Public Interface IFileCollection<BR>&= nbsp;Inherits IList<BR><BR> Overloads Sub Add(ByRef file As IFile)<BR>= <BR>End Interface<BR><BR><BR>Factory class:<BR><BR>Imports NMock<BR><BR>Fri= end Class Factory<BR><BR> Public Shared FileCollectionToReturn As Mock= <BR> Public Shared FileToReturn As Mock<BR><BR> Public Shared Sub= Reset()<BR><BR> FileCollectionToReturn =3D Nothing<BR> &= nbsp;FileToReturn =3D Nothing<BR><BR> End Sub<BR><BR> Private Sub= New()<BR> End Sub<BR><BR> Public Shared Function GetFileCollecti= on() As IFileCollection<BR><BR> Return CType(FileCollectionToRe= turn.MockInstance, IFileCollection)<BR><BR> End Function<BR><BR> = Public Shared Function GetFile() As IFile<BR><BR> Return CType(= FileToReturn.MockInstance, IFile)<BR><BR> End Function<BR><BR>End Clas= s<BR><BR><BR>Class to test:<BR><BR>Public Class Sample<BR><BR> Public = Sub DoStuff()<BR><BR> Dim file As IFile =3D Factory.GetFile()<B= R><BR> Dim collection As IFileCollection =3D Factory.GetFi= leCollection()<BR><BR> collection.Add(file)<BR><BR> End Su= b<BR><BR>End Class<BR><BR><BR>Test:<BR><BR>Imports NMock<BR>Imports NUnit.F= ramework<BR><BR><TESTFIXTURE()>=5F<BR>Public Class SampleUnitTests<BR><BR>&= nbsp;<TEST()> =5F<BR> Public Sub TestDoStuff()<BR><BR> &n= bsp;Factory.Reset()<BR><BR> Dim collection As Mock =3D New Dyna= micMock(GetType(IFileCollection))<BR> Factory.FileCollectionToR= eturn =3D collection<BR><BR> Dim file As Mock =3D New Dynamic= Mock(GetType(IFile))<BR> Factory.FileToReturn =3D file<BR><BR>&= nbsp; collection.Expect("Add", file.MockInstance)<BR><BR>  = ;Dim sampleClass As Sample =3D New Sample<BR><BR> sampleClass.D= oStuff()<BR><BR> Collection.Verify()<BR><BR> End Sub<BR><B= R>End Class<BR><BR><BR>If I do the same in C# it works as expected.<BR><BR>= Any help would be very appreciated.<BR><BR>Regards,<BR><BR>Chris.<BR><BR><B= R><BR><BR>-------------------------------------------------------<BR>SF ema= il is sponsored by - The IT Product Guide<BR>Read honest & candid revie= ws on hundreds of IT Products from real users.<BR>Discover which products t= ruly live up to the hype. Start reading now. <BR><A href=3D"http://productg= uide.itmanagersjournal.com/" target=3Dblank >http://productguide.itmanager= sjournal.com/</A><BR>=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F<BR>Nmock-general mailing list<BR>Nmo...@li...= ge.net<BR><A href=3D"https://lists.sourceforge.net/lists/listinfo/nmock-gen= eral" target=3Dblank >https://lists.sourceforge.net/lists/listinfo/nmock-ge= neral</A><BR></FONT></blockquote><br></FONT>= |