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 回答