U4-9104 Update the UmbracoExamine logic for Media to read the data directly from the umbracoXml table.
updated some tests to use the testbehavior attribute so they dont rely on being run in a specific order.
This commit is contained in:
@@ -13,6 +13,7 @@ using Umbraco.Core.Persistence.Mappers;
|
||||
|
||||
namespace Umbraco.Tests.PublishedContent
|
||||
{
|
||||
[DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
|
||||
public class LegacyExamineBackedMediaTests : ExamineBaseTest
|
||||
{
|
||||
public override void Initialize()
|
||||
|
||||
@@ -3,11 +3,13 @@ using System.Linq;
|
||||
using Examine;
|
||||
using Lucene.Net.Store;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using UmbracoExamine;
|
||||
|
||||
namespace Umbraco.Tests.UmbracoExamine
|
||||
{
|
||||
[TestFixture]
|
||||
[DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
|
||||
[TestFixture]
|
||||
public class EventsTest : ExamineBaseTest
|
||||
{
|
||||
[Test]
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Examine;
|
||||
using Examine.LuceneEngine.Config;
|
||||
using Examine.LuceneEngine.Providers;
|
||||
@@ -7,10 +9,14 @@ using Lucene.Net.Analysis;
|
||||
using Lucene.Net.Analysis.Standard;
|
||||
using Lucene.Net.Store;
|
||||
using Moq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Core.Services;
|
||||
using UmbracoExamine;
|
||||
using UmbracoExamine.Config;
|
||||
@@ -34,7 +40,8 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
IMediaService mediaService = null,
|
||||
IDataTypeService dataTypeService = null,
|
||||
IMemberService memberService = null,
|
||||
IUserService userService = null)
|
||||
IUserService userService = null,
|
||||
IContentTypeService contentTypeService = null)
|
||||
{
|
||||
if (dataService == null)
|
||||
{
|
||||
@@ -94,7 +101,8 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
long longTotalRecs;
|
||||
int intTotalRecs;
|
||||
|
||||
var allRecs = dataService.MediaService.GetLatestMediaByXpath("//node")
|
||||
var mediaXml = dataService.MediaService.GetLatestMediaByXpath("//node");
|
||||
var allRecs = mediaXml
|
||||
.Root
|
||||
.Elements()
|
||||
.Select(x => Mock.Of<IMedia>(
|
||||
@@ -114,20 +122,29 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
mt.Id == (int)x.Attribute("nodeType"))))
|
||||
.ToArray();
|
||||
|
||||
// MOCK!
|
||||
var mediaServiceMock = new Mock<IMediaService>();
|
||||
|
||||
mediaServiceMock
|
||||
.Setup(x => x.GetPagedDescendants(
|
||||
It.IsAny<int>(), It.IsAny<long>(), It.IsAny<int>(), out longTotalRecs, It.IsAny<string>(), It.IsAny<Direction>(), It.IsAny<bool>(), It.IsAny<string>())
|
||||
).Returns(() => allRecs);
|
||||
|
||||
mediaServiceMock
|
||||
.Setup(x => x.GetPagedDescendants(
|
||||
It.IsAny<int>(), It.IsAny<long>(), It.IsAny<int>(), out longTotalRecs, It.IsAny<string>(), It.IsAny<Direction>(), It.IsAny<string>())
|
||||
).Returns(() => allRecs);
|
||||
|
||||
mediaServiceMock
|
||||
.Setup(x => x.GetPagedDescendants(
|
||||
It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>(), out intTotalRecs, It.IsAny<string>(), It.IsAny<Direction>(), It.IsAny<string>())
|
||||
).Returns(() => allRecs);
|
||||
|
||||
mediaServiceMock.Setup(service => service.GetPagedXmlEntries(It.IsAny<string>(), It.IsAny<long>(), It.IsAny<int>(), out longTotalRecs))
|
||||
.Returns(() => allRecs.Select(x => x.ToXml()));
|
||||
|
||||
mediaService = mediaServiceMock.Object;
|
||||
|
||||
mediaService = Mock.Of<IMediaService>(
|
||||
x => x.GetPagedDescendants(
|
||||
It.IsAny<int>(), It.IsAny<long>(), It.IsAny<int>(), out longTotalRecs, It.IsAny<string>(), It.IsAny<Direction>(), It.IsAny<bool>(), It.IsAny<string>())
|
||||
==
|
||||
allRecs
|
||||
&& x.GetPagedDescendants(
|
||||
It.IsAny<int>(), It.IsAny<long>(), It.IsAny<int>(), out longTotalRecs, It.IsAny<string>(), It.IsAny<Direction>(), It.IsAny<string>())
|
||||
==
|
||||
allRecs
|
||||
&& x.GetPagedDescendants(
|
||||
It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>(), out intTotalRecs, It.IsAny<string>(), It.IsAny<Direction>(), It.IsAny<string>())
|
||||
==
|
||||
allRecs);
|
||||
}
|
||||
if (dataTypeService == null)
|
||||
{
|
||||
@@ -139,6 +156,18 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
memberService = Mock.Of<IMemberService>();
|
||||
}
|
||||
|
||||
if (contentTypeService == null)
|
||||
{
|
||||
var contentTypeServiceMock = new Mock<IContentTypeService>();
|
||||
contentTypeServiceMock.Setup(x => x.GetAllContentTypes())
|
||||
.Returns(new List<IContentType>()
|
||||
{
|
||||
new ContentType(-1) {Alias = "Folder", Name = "Folder", Id = 1031, Icon = "icon-folder"},
|
||||
new ContentType(-1) {Alias = "Image", Name = "Image", Id = 1032, Icon = "icon-picture"}
|
||||
});
|
||||
contentTypeService = contentTypeServiceMock.Object;
|
||||
}
|
||||
|
||||
if (analyzer == null)
|
||||
{
|
||||
analyzer = new StandardAnalyzer(Version.LUCENE_29);
|
||||
@@ -154,6 +183,7 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
mediaService,
|
||||
dataTypeService,
|
||||
userService,
|
||||
contentTypeService,
|
||||
analyzer,
|
||||
false);
|
||||
|
||||
|
||||
@@ -10,15 +10,17 @@ using Lucene.Net.Index;
|
||||
using Lucene.Net.Search;
|
||||
using Lucene.Net.Store;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using UmbracoExamine;
|
||||
|
||||
namespace Umbraco.Tests.UmbracoExamine
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Tests the standard indexing capabilities
|
||||
/// </summary>
|
||||
[TestFixture, RequiresSTA]
|
||||
/// <summary>
|
||||
/// Tests the standard indexing capabilities
|
||||
/// </summary>
|
||||
//[DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
|
||||
[TestFixture, RequiresSTA]
|
||||
public class IndexTest : ExamineBaseTest
|
||||
{
|
||||
|
||||
@@ -85,12 +87,11 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
//RESET the parent id
|
||||
existingCriteria = ((IndexCriteria)_indexer.IndexerData);
|
||||
_indexer.IndexerData = new IndexCriteria(existingCriteria.StandardFields, existingCriteria.UserFields, existingCriteria.IncludeNodeTypes, existingCriteria.ExcludeNodeTypes,
|
||||
null);
|
||||
null);
|
||||
|
||||
//now ensure it's deleted
|
||||
var newResults = _searcher.Search(_searcher.CreateSearchCriteria().Id(2112).Compile());
|
||||
Assert.AreEqual(1, newResults.Count());
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -8,9 +8,11 @@ using Examine.LuceneEngine.Providers;
|
||||
using Lucene.Net.Store;
|
||||
using NUnit.Framework;
|
||||
using Examine.LuceneEngine.SearchCriteria;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
|
||||
namespace Umbraco.Tests.UmbracoExamine
|
||||
{
|
||||
[DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
|
||||
[TestFixture]
|
||||
public class SearchTests : ExamineBaseTest
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user