.net - Using events declared in Visual Basic 6.0 in a dotnet application -
we writing tests com library written in vb 6.0.the problem facing that, unable access events declared in vb( withevents). exception, "object not support set of events". how can overcome problem?
your mocking framework problem here. mock object returned call:
repository.dynamicmock<personlib.databasecommand>();
implements databasecommand
class's interface, not mock events. therefore, when pass instance of mock object vb6 code, expects receive databasecommand object can raise events, won't work.
when pass mock object personclass.init
method, here simplified version of happening:
the code gets line in
personclass.init
:set dbcommand = vdbcommand
vb6 asks object on right-hand side of
set
statement if supports same eventsdatabasecommand
class (vb6 because declareddbcommand
withevents
keyword, try set event sink receive eventsdbcommand
object).the object passed in, however, being mock object , not real
databasecommand
object, doesn't implement events realdatabasecommand
class implements. when vb6 encounters this, raises error seeing.
i can't think of way make mock object support same events databasecommand
class in order make test code work (well, can think of 1 way, involve redesigning classes), may post more later if find more reasonable solution.
Comments
Post a Comment