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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top