2012-01-18 5 views
1

일부 조롱 한 EPiServer 속성을 사용하여 코드 일부를 테스트하고 있습니다. 그리고 저는 이러한 속성을 새롭게하면서 예외를 얻습니다. 이 충돌 라인입니다 :조롱 된 EPiServer 속성을 사용하여 단위 테스트를 실행하지 못했습니다.

var englishContent = new PropertyXhtmlString { 
    Name = "EnglishOperationsMessage", 
    LongString = "Message content in english"}; 

을 그리고 여기에 생성 된 예외 :이 문제를 해결하는 방법을 모든 단서가 크게 감상 할 수

SetUp : System.TypeInitializationException : 
The type initializer for 'EPiServer.Util.AutoCompressString' threw an exception. 
----> System.IO.FileNotFoundException : Could not find file 'D:\Projects\Antenor-Management-System\Ams.Presenter.Test\bin\Debugweb.config'. 
at EPiServer.Core.PropertyLongString.SetDefaultValue() 
at EPiServer.SpecializedProperties.PropertyXhtmlString..ctor() 
at Ams.Presenter.Test.Login.OperationsMessageTest.GetMockCollection() in OperationsMessageTest.cs: line 58 
at Ams.Presenter.Test.Login.OperationsMessageTest.TestSetUp() in OperationsMessageTest.cs: line 19 
--FileNotFoundException 
at EPiServer.ConfigFileSettings.ᐁ() 
at EPiServer.ConfigFileSettings.get_AllAppSettings() 
at EPiServer.ApplicationConfiguration..ctor(String configFileName) 
at EPiServer.ApplicationConfiguration..ctor(String configFileName, String rootVirtualPath) 
at EPiServer.Global.get_EPConfig() 
at EPiServer.Util.AutoCompressString..cctor() 

은! 이 점은 EPiServer 6.42B를위한 것입니다.

답변

0

:

Global.EPConfig["EPfEnableFriendlyURL"] 

문제는 장치 코드를 테스트하는 동안 EPiServer.Global newed가되지 않는다는 것이다. 나는 그것이 어떻게 든 조롱받을 수 있는지 알아봐야 할 것입니다.

0

(PropertyXhtmlString에서 사용하는) AutoCompressString 클래스의 생성자는 초기화하는 동안 구성 파일에서 일부 값을 찾습니다. 구성 파일을 찾을 수 없어 초기화하지 못했습니다. 귀하의 경우에는

의 해당 파일이 해당 위치에 존재 하는가

D:\Projects\Antenor-Management-System\Ams.Presenter.Test\bin\Debugweb.config 

의 설정 파일을 찾고? 호출이 Global.EPConfig하게된다 PropertyXhtmlString를 렌더링하는 방법에

+0

아니요. 먼저 테스트중인 코드에서 is가 사용하는 파일을 찾아서 원하는 위치에 복사합니다. 잘하면 그 트릭을 할 것입니다 ... 사실, 난 빈 파일로 시작하고 어쩌면 정확히 생성자에 의해 원하는 것을 알아낼 수있을 것 같아요. – JustAnotherCoder

+0

흠, 그 파일은 내 시스템에 전혀 없습니다 ... (예, 테스트중인 코드는 예외를 트리거하지 않고 해당 클래스의 객체를 생성 할 수 있습니다). 생성자를 파내는 시간. – JustAnotherCoder

관련 문제