1

コードの一部をテストするために、いくつかのモックされた 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 用です。

4

2 に答える 2

0

AutoCompressStringクラスのコンストラクター(PropertyXhtmlStringで使用)は、初期化中に構成ファイルからいくつかの値を探します。設定ファイルが見つからないため、初期化に失敗しています。

あなたの場合、設定ファイルを探しています

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

そのファイルはその場所に存在しますか?

于 2012-01-18T15:04:26.200 に答える
0

PropertyXhtmlString をレンダリングするメソッドで、Global.EPConfig への呼び出しが行われます。

Global.EPConfig["EPfEnableFriendlyURL"]

問題は、コードの単体テスト中に EPiServer.Global が更新されないことです。どうにかしてモックアップできるかどうかを確認する必要があります。

于 2012-01-19T09:45:29.293 に答える