2016-10-10 3 views
0

각 테스트 설정에서 컨테이너를 설치하는 통합 테스트를 작성하고 있습니다. 나는 등록 코드를 재사용하고있어,하지만 난이 오류가 Lifestyle.Scoped와 종속성을 등록하려고 오류가 발생합니다 :유닛 테스트 중에 어떤 간단한 인젝터 범위 라이프 스타일을 사용해야합니까?

내 경우에 사용한다 무엇 DefaultScopedLifestyle

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.

? 범위는 실제로 싱글 톤이어야하지만 webapi 앱에서 등록 코드를 재사용한다는 것을 기억하십시오.

답변

2

통합 테스트 시나리오의 경우 사용할 수있는 유효 라이프 스타일은 Per Lifetime ScopePer Execution Context Scope입니다. Per Lifetime Scope은 스레드에 바인딩 된 범위를 정의 할 수 있으며 Per Execution Contest Scope에서는 비동기 작업을 통해 이동하는 범위를 정의 할 수 있습니다.

관련 문제