Merge remote-tracking branch 'origin/v12/dev' into v13/dev

# Conflicts:
#	src/Umbraco.Core/PropertyEditors/DataValueReferenceFactoryCollection.cs
#	src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentRepositoryBase.cs
#	src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyValueEditor.cs
#	tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueEditorReuseTests.cs
#	tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueReferenceFactoryCollectionTests.cs
This commit is contained in:
Bjarke Berg
2024-01-23 10:15:49 +01:00
17 changed files with 323 additions and 187 deletions

View File

@@ -1,4 +1,3 @@
using System.Linq;
using Microsoft.Extensions.Logging;
using Moq;
using NUnit.Framework;
@@ -16,6 +15,7 @@ public class DataValueEditorReuseTests
{
private Mock<IDataValueEditorFactory> _dataValueEditorFactoryMock;
private PropertyEditorCollection _propertyEditorCollection;
private DataValueReferenceFactoryCollection _dataValueReferenceFactories;
[SetUp]
public void SetUp()
@@ -32,6 +32,7 @@ public class DataValueEditorReuseTests
Mock.Of<IIOHelper>()));
_propertyEditorCollection = new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<IDataEditor>));
_dataValueReferenceFactories = new DataValueReferenceFactoryCollection(Enumerable.Empty<IDataValueReferenceFactory>);
_dataValueEditorFactoryMock
.Setup(m =>
@@ -40,6 +41,7 @@ public class DataValueEditorReuseTests
new DataEditorAttribute("a", "b", "c"),
new BlockListEditorDataConverter(),
_propertyEditorCollection,
_dataValueReferenceFactories,
Mock.Of<IDataTypeService>(),
Mock.Of<IContentTypeService>(),
Mock.Of<ILocalizedTextService>(),
@@ -95,7 +97,7 @@ public class DataValueEditorReuseTests
{
var blockListPropertyEditor = new BlockListPropertyEditor(
_dataValueEditorFactoryMock.Object,
new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<IDataEditor>)),
_propertyEditorCollection,
Mock.Of<IIOHelper>(),
Mock.Of<IEditorConfigurationParser>(),
Mock.Of<IBlockValuePropertyIndexValueFactory>());
@@ -116,7 +118,7 @@ public class DataValueEditorReuseTests
{
var blockListPropertyEditor = new BlockListPropertyEditor(
_dataValueEditorFactoryMock.Object,
new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<IDataEditor>)),
_propertyEditorCollection,
Mock.Of<IIOHelper>(),
Mock.Of<IEditorConfigurationParser>(),
Mock.Of<IBlockValuePropertyIndexValueFactory>());

View File

@@ -176,14 +176,11 @@ public class DataValueReferenceFactoryCollectionTests
{
var collection = new DataValueReferenceFactoryCollection(Enumerable.Empty<IDataValueReferenceFactory>);
var propertyEditors = new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<IDataEditor>));
var properties = new PropertyCollection();
var resultA = collection.GetAutomaticRelationTypesAliases(propertyEditors).ToArray();
var resultB = collection.GetAutomaticRelationTypesAliases(properties, propertyEditors).ToArray();
var result = collection.GetAllAutomaticRelationTypesAliases(propertyEditors).ToArray();
var expected = Constants.Conventions.RelationTypes.AutomaticRelationTypes;
CollectionAssert.AreEquivalent(expected, resultA, "Result A does not contain the expected relation type aliases.");
CollectionAssert.AreEquivalent(expected, resultB, "Result B does not contain the expected relation type aliases.");
CollectionAssert.AreEquivalent(expected, result, "Result does not contain the expected relation type aliases.");
}
[Test]
@@ -194,15 +191,11 @@ public class DataValueReferenceFactoryCollectionTests
var labelPropertyEditor = new LabelPropertyEditor(DataValueEditorFactory, IOHelper, EditorConfigurationParser);
var propertyEditors = new PropertyEditorCollection(new DataEditorCollection(() => labelPropertyEditor.Yield()));
var serializer = new ConfigurationEditorJsonSerializer();
var property = new Property(new PropertyType(ShortStringHelper, new DataType(labelPropertyEditor, serializer)));
var properties = new PropertyCollection { property, property }; // Duplicate on purpose to test distinct aliases
var resultA = collection.GetAutomaticRelationTypesAliases(propertyEditors).ToArray();
var resultB = collection.GetAutomaticRelationTypesAliases(properties, propertyEditors).ToArray();
var result = collection.GetAllAutomaticRelationTypesAliases(propertyEditors).ToArray();
var expected = Constants.Conventions.RelationTypes.AutomaticRelationTypes.Append("umbTest");
CollectionAssert.AreEquivalent(expected, resultA, "Result A does not contain the expected relation type aliases.");
CollectionAssert.AreEquivalent(expected, resultB, "Result B does not contain the expected relation type aliases.");
CollectionAssert.AreEquivalent(expected, result, "Result does not contain the expected relation type aliases.");
}
private class TestDataValueReferenceFactory : IDataValueReferenceFactory