chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Hi All,

I'm trying to mock a generic interface twice in the same test using a different type for the generic. For example Interface<string> and Interace<int>. However, I keep getting an error when I go to get the mock object. The problem, I think, is that the mock manager is not treating these as different mock objects, and when casting the return of the object from the mock object it is failing.

Is this normal? Should I be doing something different?

Thanks,

Pleb

Here's my unit test

[Test]
[ClearMocks]
public void ConstructorTest3()
{
    MockObject<INotify<string>> stringNotifier = MockManager.MockObject<INotify<string>>();
    MockObject<INotify<UserLoginAuthenticationResult>> resultNotifier = MockManager.MockObject<INotify<UserLoginAuthenticationResult>>();

    UserLoginAuthenticationService loginService = new UserLoginAuthenticationService(stringNotifier.Object, resultNotifier.Object);
}
asked by pleb (720 points)

2 Answers

0 votes
Hi Pleb,

It appears that you have found a bug. :(
Ive checked it out and indeed what you describe is more or less true. it looks that the Isolator is confusing between these types.

Anyway, we will work on fixing this and update you when the fix is ready.
answered by lior (13.2k points)
0 votes
Hi Lior,

Thanks for the quick reply. Bugs are annoying, but thanks for identifying it and confirming it.

I'll wait till next release.... no biggie :D
answered by pleb (720 points)
...