gpt4 book ai didi

sitecore - Sitecore FakeDB 测试的最小 Nugets 占用空间是多少?

转载 作者:行者123 更新时间:2023-12-01 09:17:44 25 4
gpt4 key购买 nike

我从标准的 Sitecore.KernelSitecore.Nexus 开始。 Sitecore 在这里给出了非常详细的错误信息,所以我也添加了 DependencyInjection。它带来了很多依赖关系,它们没有显示在下面的配置中。如您所见,我使用 Sitecore 包的 *.NoReferences 版本来控制依赖关系。

<packages>
<package id="Microsoft.Extensions.DependencyInjection" version="1.0.0" targetFramework="net452" />
<package id="Sitecore.FakeDb" version="1.2.2" targetFramework="net452" />
<package id="Sitecore.Kernel.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
<package id="Sitecore.Nexus.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
</packages>

之后我就卡住了。我收到一个错误,并没有提供太多关于遗漏的线索:

System.NullReferenceException : Object reference not set to an instance of an object.
at Sitecore.Configuration.DefaultFactory.CreateType(XmlNode configNode, String[] parameters, Boolean assert)
at Sitecore.Configuration.DefaultFactory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert)
at Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper)
at Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert)
at Sitecore.Configuration.DefaultFactory.CreateObject(String configPath, String[] parameters, Boolean assert)
at Sitecore.Configuration.DefaultFactory.CreateObject(String configPath, Boolean assert)
at Sitecore.Configuration.DefaultFactory.GetDatabase(String name, Boolean assert)
at Sitecore.Configuration.DefaultFactory.GetDatabase(String name)
at Sitecore.Configuration.Factory.GetDatabase(String name)
at Sitecore.Data.Database.GetDatabase(String databaseName)
at Sitecore.FakeDb.Db..ctor(String databaseName)
at Sitecore.FakeDb.Db..ctor()
at SitecoreTests.Class1.HowToCreateSimpleItem() in C:\prog\temp\SitecoreTests\SitecoreTests\Class1.cs:line 17

那么,让简单的 Fake DB 测试工作还缺少什么?

最佳答案

在尝试了所有在完整 Sitecore.Kernel 中作为依赖项引用的包之后,我以这个设置结束:

<packages>
<package id="Lucene.Net" version="3.0.3" targetFramework="net452" />
<package id="Microsoft.Extensions.DependencyInjection" version="1.0.0" targetFramework="net452" />
<package id="Sitecore.FakeDb" version="1.2.2" targetFramework="net452" />
<package id="Sitecore.Kernel.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
<package id="Sitecore.Logging.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
<package id="Sitecore.Nexus.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
</packages>

现在很明显,如果没有 Sitecore.Logging,Sitecore 就无法启动。

Lucene.Net 也是必需的,但它的错误更有帮助:

System.IO.FileNotFoundException : Could not load file or assembly 'Lucene.Net, Version=3.0.3.0, Culture=neutral, PublicKeyToken=85089178b9ac3181' or one of its dependencies. The system cannot find the file specified.

附:如果你不关心引用额外的 DLL,你可以只添加两个包来让你测试工作 - Sitecore.Nexus(没有 .NoReferences)和 Microsoft.Extensions .DependencyInjection

关于sitecore - Sitecore FakeDB 测试的最小 Nugets 占用空间是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39802162/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com