Question

I have a problem in C# unit test. When I test some methods, They are need to convert original interface. like this:

_stubInterface1 = MockRepository.GenerateMock<Interface1>();
...
var someData = (Interface1)_stubInterface1;

Then CLR throw exception. Do you have any idea?

Was it helpful?

Solution

Sorry. My question has error. I mean that:

_stubInterface1 = MockRepository.GenerateMock<Interface1>();
...
var someData = (Interface2)_stubInterface2;

solution:

_stubInterface1 = MockRepository.GenerateMock<Interface1,Interface2>();
...
var someData = (Interface2)_stubInterface2;

Thanks all reply and all guys.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top