1

내 테스트 프로젝트에서 종속성 주입을 위해 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)

답변

0

그것은 흥미 롭습니다. 찾았습니다 this blog post that may help your issue. MSTest가 작업 디렉토리로 사용하고있는 것처럼 보입니다.이 말은 귀찮은 말입니다. 블로그 게시물은 디렉토리를 변경하는 방법을 보여 주므로 일관된 결과를 얻을 수 있습니다. 좀 더 우아한 해결책이 있는지 알아보기 위해 인터넷 검색을 할 것입니다.

0

그것은 저장소 구현을 보유하고 어셈블리 같은 소리 (bin 디렉토리에서 누락 또는 실행 디렉토리는을위한 곳 짓다).

먼저 빌드 서버의 실행 디렉터리에 어셈블리가 있는지 확인합니다.

이 존재하는 경우, 그때는 어셈블리의 버전 즉, 올바른 있는지 확인하십시오 것 등 네임 스페이스 같은에서 그것에 저장소 구현이

이 될 수 빌드 서버 VS가 실행/빌드하고있는 곳 이외의 곳에서 오브젝트를 실행/빌드하고 있습니다.

+0

그럴듯한 소리가 들리 겠지만 어떻게해야합니까? 어떤 디렉토리가 TFS에서 테스트를 수행합니까? 내가 검사하고, 저장소 dll이 분명히 server \ Build_output \ Example Project Nightly_20080919.9 \ TestResults \ 9598f1df-cd1d-49b2-a915-4ee06532ef9f \ Out (나머지 파일은 있지만)에 배포되지 않아야합니다. 자동으로? (결국 프로젝트 참조이므로 copy local은 true로 설정됩니다.) – ampburner

+0

TFS가 솔루션을 얼마나 정확하게 빌드하는지 잘 모르겠습니다 만 빌드 경로 정보가 상위 디렉토리 중 하나에 들어갈 수 있습니다. 서버 \ Build_output \ 예제 프로젝트 Nightly_20080919.9. 폴더에 배포되지 않는 유일한 참조입니까? 지금은 다음과 같은 작업을 시도해 볼 수 있습니다. - 어셈블리를 TFS Out 디렉토리에 복사하는 msbuild 대상을 추가하십시오. 불행히도 TFS에서이 작업을 수행하는 방법을 알지 못합니다. - 테스트 설정 방법에서 AppDomain.CurrentDomain.BaseDirectory의 값을 기록하십시오. 이것은 응용 프로그램이 어셈블리를 찾기 위해 사용하는 디렉토리를 알려줍니다. – Gilligan

+0

hmmm .... AppDomain.CurrentDomain.BaseDirectory는 분명히 D : \ Microsoft Visual Studio 9.0 \ Common7 \ IDE \? – ampburner