Files
Umbraco-CMS/tests/Umbraco.Tests.Integration/Umbraco.Examine.Lucene/UmbracoExamine/ExamineDemoDataContentService.cs
Paul Johnson 00133e880d Move test projects from src/ to tests/ (#11357)
* Update gitignore

* Move csproj

* Update project references

* Update solutions

* Update build scripts

* Tests used to share editorconfig with projects in src

* Fix broken tests.

* Stop copying around .editorconfig

merged root one with linting

* csharp_style_expression_bodied -> suggestion

* Move StyleCop rulesets to matching directories and update shared build properties

* Remove legacy build files, update NuGet.cofig and solution files

* Restore myget source

* Clean up .gitignore

* Update .gitignore

* Move new test classes to tests after merge

* Gitignore + nuget config

* Move new test

Co-authored-by: Ronald Barendse <ronald@barend.se>
2021-10-18 08:14:04 +01:00

57 lines
1.7 KiB
C#

using System.Xml.Linq;
using System.Xml.XPath;
namespace Umbraco.Cms.Tests.Integration.Umbraco.Examine.Lucene.UmbracoExamine
{
// TODO: This is ultra hack and still left over from legacy but still works for testing atm
public class ExamineDemoDataContentService
{
public const int ProtectedNode = 1142;
public ExamineDemoDataContentService(string contentXml = null)
{
if (contentXml == null)
{
contentXml = TestFiles.umbraco;
}
_xContent = XDocument.Parse(contentXml);
}
/// <summary>
/// Return the XDocument containing the xml from the umbraco.config xml file
/// </summary>
/// <param name="xpath"></param>
/// <returns></returns>
/// <remarks>
/// This is no different in the test suite as published content
/// </remarks>
public XDocument GetLatestContentByXPath(string xpath)
{
var xdoc = XDocument.Parse("<content></content>");
xdoc.Root.Add(_xContent.XPathSelectElements(xpath));
return xdoc;
}
/// <summary>
/// Return the XDocument containing the xml from the umbraco.config xml file
/// </summary>
/// <param name="xpath"></param>
/// <returns></returns>
public XDocument GetPublishedContentByXPath(string xpath)
{
return GetContentByXPath(xpath, _xContent);
}
private XDocument GetContentByXPath(string xpath, XDocument content)
{
var xdoc = XDocument.Parse("<content></content>");
xdoc.Root.Add(content.XPathSelectElements(xpath));
return xdoc;
}
private readonly XDocument _xContent;
}
}