我無法設置Spring.Net的配置,因此我可以使用Rhino Mocks生成一個模擬對象。我意識到GenerateMock是一個靜態方法,所以我需要在配置中使用工廠方法,但我無法使它工作。這是我使用的配置:爲靜態生成Spring.Net和Rhino Mocks的配置GenerateMock <>
<object id="exampleObject"
type="Rhino.Mocks.MockRepository, Rhino.Mocks"
factory-method="GenerateMock&lt;MyAssembly.MyInterface>" />
在我的代碼
然後(這是一個單元測試)我使用:
using (IApplicationContext ctx = ContextRegistry.GetContext()) {....}
,但我得到了以下錯誤消息:
System.Configuration.ConfigurationErrorsException: Error creating context 'spring.root': Could not load type from string value 'MyAssembly.MyInterface'. ---> System.TypeLoadException: Could not load type from string value 'MyAssembly.MyInterface'..
任何想法,爲什麼我可能會得到錯誤?
謝謝你。我也意識到,我遺漏了使其失敗的singleton =「false」屬性。再次感謝,困惑。 – Confused 2009-02-16 15:32:57