版本:C#4.0,Spring.Net 1.3.2,RhinoMocks 3.6.1
鉴于这两个界面:
public interface IDivisionSelectView
{
// ...
}
public interface ILoginView
{
IDivisionSelectView DivisionSelectView { get; }
// ...
}
我正在尝试使用Spring.Net来使用Rhino.Mocks.MockRepository.GenerateMock<>()
工厂为ILoginView
创建一个代理对象,其 DivisionSelectView 属性自动设置为{{ 1}}代理(使用相同的工厂)。这是Spring XML:
IDivisionSelectView
这是调用C#代码:
<object id="IDivisionSelectView"
type="Rhino.Mocks.MockRepository, Rhino.Mocks"
factory-method="GenerateMock<[Asm.Ns.IDivisionSelectView, Asm]>"
singleton="false">
<constructor-arg name="argumentsForConstructor">
<list element-type="System.Object, mscorlib">
</list>
</constructor-arg>
</object>
<object id="ILoginView"
type="Rhino.Mocks.MockRepository, Rhino.Mocks"
factory-method="GenerateMock<[Asm.Ns.ILoginView, Asm]>"
singleton="false">
<constructor-arg name="argumentsForConstructor">
<list element-type="System.Object, mscorlib">
</list>
</constructor-arg>
<property name="DivisionSelectView" ref="IDivisionSelectView">
</property>
</object>
这是我得到的错误:
IApplicationContext ctx = new XmlApplicationContext(
"assembly://Asm/Asm/spring.xml");
ContextRegistry.RegisterContext(ctx);
ILoginView view = ctx.GetObject("ILoginView") as ILoginView;
Spring.Objects.Factory.ObjectCreationException was unhandled by user code
这可能吗?
答案 0 :(得分:0)
ILoginView上的DivisionSelectView属性没有setter。