내 테스트 프로젝트에서 종속성 주입을 위해 Castle Windsor를 사용하고 있습니다. 내 '저장소'클래스의 인스턴스 하나를 만들려고합니다. "내 컴퓨터에서 잘 작동합니다."하지만 TFS에서 야간 빌드를 실행하면 내 테스트에서 해당 클래스를로드 할 수 없습니다.성 (Castle)을 사용하여 테스트 프로젝트 (TFS 2008)에서 의존성 주입을 수행하는 방법
private static readonly WindsorContainer _container = new WindsorContainer(new XmlInterpreter());
public void MyTestInitialize()
{
var testRepository = (IBogusRepository)_container[typeof(IBogusRepository)];
}
XML 구성 : 나는 다음과 같은 메시지가 생성하는 새 빌드 큐하면
<castle>
<components>
<component id="primaryBogusRepository" type="Example2008.Repository.LALALALALA, Example2008.Repository" service="Example2008.Domain.Repository.IBogusRepository, Example2008.Domain" />
<component id="primaryProductRepository" type="Example2008.Repository.ProductRepository, Example2008.Repository" service="Example2008.Domain.Repository.IProductRepository, Example2008.Domain" />
</components>
</castle>
:이 메시지에서
Unable to create instance of class Example2008.Test.ActiveProductRepositoryTest. Error: System.Configuration.ConfigurationException: The type name Example2008.Repository.LALALALALA, Example2008.Repository could not be located.
Castle.Windsor.Installer.DefaultComponentInstaller.ObtainType(String typeName) Castle.Windsor.Installer.DefaultComponentInstaller.SetUpComponents(IConfiguration[] configurations, IWindsorContainer container) Castle.Windsor.Installer.DefaultComponentInstaller.SetUp(IWindsorContainer container, IConfigurationStore store) Castle.Windsor.WindsorContainer.RunInstaller() Castle.Windsor.WindsorContainer..ctor(IConfigurationInterpreter interpreter) Example2008.Test.ActiveProductRepositoryTest..cctor() in d:\Code_Temp\Example Project Nightly\Sources\Example2008.Test\ProductRepositoryTest.cs: line 19
를, (내 구성이 올 것 같다 그것을 구체적인 클래스 'LALALALALA'를 인스턴스화하고 싶다는 것을 알 수 있습니다. 따라서 xml 설정은 분명히 올바르게 빨간색입니다.
필자는 필자의 의존성을 올바르게 설정했다고 생각합니다. 솔루션을 정리하고 다시 작성하더라도 로컬로 작동하기 때문입니다.
의견이 있으십니까?
(그런데 사용 VS2008, TFS 2008.Net 3.5, 성 1.03)
그럴듯한 소리가 들리 겠지만 어떻게해야합니까? 어떤 디렉토리가 TFS에서 테스트를 수행합니까? 내가 검사하고, 저장소 dll이 분명히 server \ Build_output \ Example Project Nightly_20080919.9 \ TestResults \ 9598f1df-cd1d-49b2-a915-4ee06532ef9f \ Out (나머지 파일은 있지만)에 배포되지 않아야합니다. 자동으로? (결국 프로젝트 참조이므로 copy local은 true로 설정됩니다.) – ampburner
TFS가 솔루션을 얼마나 정확하게 빌드하는지 잘 모르겠습니다 만 빌드 경로 정보가 상위 디렉토리 중 하나에 들어갈 수 있습니다. 서버 \ Build_output \ 예제 프로젝트 Nightly_20080919.9. 폴더에 배포되지 않는 유일한 참조입니까? 지금은 다음과 같은 작업을 시도해 볼 수 있습니다. - 어셈블리를 TFS Out 디렉토리에 복사하는 msbuild 대상을 추가하십시오. 불행히도 TFS에서이 작업을 수행하는 방법을 알지 못합니다. - 테스트 설정 방법에서 AppDomain.CurrentDomain.BaseDirectory의 값을 기록하십시오. 이것은 응용 프로그램이 어셈블리를 찾기 위해 사용하는 디렉토리를 알려줍니다. – Gilligan
hmmm .... AppDomain.CurrentDomain.BaseDirectory는 분명히 D : \ Microsoft Visual Studio 9.0 \ Common7 \ IDE \? – ampburner