rip*_*234 17 c# rhino-mocks mocking stub sealed
运行此代码:
_foo = MockRepository.GenerateStub<IBar>();
_foo.Stub(x => x.Foo()).Return("sdf");
Run Code Online (Sandbox Code Playgroud)
什么时候
public interface IBar
{
string Foo();
}
public class Bar : IBar
{
public string Foo()
{
throw new NotImplementedException();
}
}
Run Code Online (Sandbox Code Playgroud)
抛出NotSupportedException - "无法创建密封类的模拟".我明白为什么你不能模拟一个密封的类(虽然在TypeMock中有解决方案),但是模拟一个返回密封类(字符串)的类有什么问题?