2016-10-10 23 views
0

我正在編寫集成測試,在每個測試設置上設置一個容器。我重用註冊碼,但我得到試圖註冊與Lifestyle.Scoped依賴我得到這個錯誤時的錯誤:哪種簡單的注射器適用範圍的生活方式應該在單元測試中使用?

SetUp : System.InvalidOperationException : To be able to use the Lifestyle.Scoped property, please ensure that the container is configured with a default scoped lifestyle by setting the Container.Options.DefaultScopedLifestyle property with the required scoped lifestyle for your type of application.

我應該在我的情況下使用什麼DefaultScopedLifestyle?範圍應該是單身人士,但請記住,我正在重複使用來自webapi應用程序的註冊碼。

回答

2

爲了整合測試場景,可以使用的範圍的生活方式是Per Lifetime ScopePer Execution Context Scope。 Per Lifetime Scope允許定義綁定到線程的範圍,而Per Execution Contest Scope允許定義一個將在異步操作上流動的範圍。

相關問題