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?

Était-ce utile?

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top