New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sitecore 8.2 - Could not create instance of type: Sitecore.Data.Database. No matching constructor was found. #139
Comments
@derekzernach thanks for reporting the issue. Sitecore 8.2 introduced new DI model. This impacted 'old good' To make your tests pass please add the <?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<databases>
<database id="core">
<patch:attribute name="type">Sitecore.Data.DefaultDatabase, Sitecore.Kernel</patch:attribute>
</database>
<database id="master">
<patch:attribute name="type">Sitecore.Data.DefaultDatabase, Sitecore.Kernel</patch:attribute>
</database>
<database id="web">
<patch:attribute name="type">Sitecore.Data.DefaultDatabase, Sitecore.Kernel</patch:attribute>
</database>
</databases>
<!-- EVENTING -->
<eventing defaultProvider="sitecore">
<providers>
<clear />
<add name="sitecore" type="Sitecore.Eventing.EventProvider, Sitecore.Kernel" systemDatabaseName="core" />
</providers>
</eventing>
</sitecore>
</configuration> You might also need to reference Microsoft DependencyInjection nuget package in tests and upgrade your solution to .NET 4.5.2. |
This definitely works! Can this patch config be referenced from the bin folder in any way? I'm using nuget to install this file along with a DLL to all my testing projects and the new version of nuget doesn't add files to projects anymore. |
@derekzernach yes it can. Despite FakeDb allows using auto-include files, they look a bit awkward when used in unit tests. The solution I suggested above could be applied without the necessity to update FakeDb but I'd definitely like to find more elegant way to solve this. The <!-- DATABASE TYPE
For Sitecore versions prior to 8.2 should be 'Sitecore.Data.Database, Sitecore.Kernel'.
For Sitecore 8.2 and later should be 'Sitecore.Data.DefaultDatabase, Sitecore.Kernel'. -->
<sc.variable name="databaseType" value="Sitecore.Data.Database, Sitecore.Kernel" /> |
…#139 - still do not work
Implemented in v1.2.0. |
If I use Sitecore.Kernel 8.2.160729 I get the below error. No AutoFixture.Xunit tests will run on the new Sitecore.Kernel 8.2.160729 DLL
Sitecore.Exceptions.ConfigurationException
Could not create instance of type: Sitecore.Data.Database. No matching constructor was found.
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.GetDatabase(String name, Boolean assert)
at Sitecore.Configuration.DefaultFactory.GetDatabase(String name)
at Sitecore.FakeDb.Db..ctor(String databaseName)
The text was updated successfully, but these errors were encountered: