.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:

  1. the code gets line in personclass.init:

    set dbcommand = vdbcommand

  2. vb6 asks object on right-hand side of set statement if supports same events databasecommand class (vb6 because declared dbcommand withevents keyword, try set event sink receive events dbcommand object).

  3. the object passed in, however, being mock object , not real databasecommand object, doesn't implement events real databasecommand 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

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -