.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 = vdbcommandvb6 asks object on right-hand side of
setstatement if supports same eventsdatabasecommandclass (vb6 because declareddbcommandwitheventskeyword, try set event sink receive eventsdbcommandobject).the object passed in, however, being mock object , not real
databasecommandobject, doesn't implement events realdatabasecommandclass 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