SourceForge has been redesigned. Learn more.
Close

#14 NMock2: Mock object can't be passed as an object parameter

open
nobody
Mocks (4)
5
2008-01-13
2006-07-19
Anonymous
No

I am trying to use NMock2 with Windows Workflow
Foundation. For WF, I've defined an interface such
as the following:

[ExternalDataExchange]
public interface IMyService {
void DoSomething();
}

Inside of my test code, I'm getting a mock object
using something like the following code:

IMyService mockService =
mockery.NewMock<IMyService>();

At this point, the mock object appears to be fine and
the following condition is met:

mockService is IMyService == true

The ExternalDataExchangeService class in WF, has a
method named AddService that I need to pass my mock
object to in order to allow the workflow to call my
service. The signature for AddService is:

void AddService(object service)

When I pass my mock object to AddService() or to any
other method that accepts a System.Object type as a
parameter, the mock object doesn't appear to
implement the interface in the called method.
Basically, in the called code:

mockService is IMyService == false

This works with NMock v1, and I think it's related to
the use of transparent proxies in NMock v2.

I can be contacted at
michael@nospam.imaginaryrealities.com for more
information.

Michael Collins

Discussion

  • Nobody/Anonymous

    Logged In: NO

    This is true of any IServiceContainer as well. Currently I
    don't have access to my code, but I'll upload a patch
    against this bug that I had to fix for my internal
    projects. I have unit tests for my issue, but it would be
    nice to know if it fixes your issue as well.

    Steven Mitcham

     
  • Steve Mitcham

    Steve Mitcham - 2007-10-12

    Logged In: YES
    user_id=1572889
    Originator: NO

    This should be fixed, although I would not want to attach a dependency to the workflow libraries to the main set of tests. If someone with a knowledge of the WF can create a stand-alone test to verify this I'd appreciate it.

     
  • Richard A. Holden III

    • labels: --> Mocks
     

Log in to post a comment.