起订量属性我想MOQ下一个对象:与保护的setter
abstract class Foo
{
public string Bar { get; protected set; }
}
使new Mock<Foo>().Bar
回报"Blah"
。
我该怎么做?
fooMock.SetupGet<string>(s => s.Bar).Returns("Blah");
抛出
故障:System.NotSupportedException:一个非虚拟部件上无效设置:S => s.Date
和
fooMock.Protected().SetupGet<string>("Bar").Returns("Blah");
投掷
要指定公物StatementSection.Date的设置,使用类型重载
那么如何行动?使用反射调用属性setter?修改属性使虚拟? – abatishchev 2011-01-26 17:01:09