Merge branch 'main' into v17/dev
# Conflicts: # tests/Umbraco.Tests.UnitTests/Umbraco.Tests.Common/Builders/PropertyTypeBuilderTests.cs
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Strings;
|
||||
using Umbraco.Cms.Tests.Common.Builders;
|
||||
using Umbraco.Cms.Tests.Common.Builders.Extensions;
|
||||
|
||||
@@ -15,9 +16,27 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Models;
|
||||
public class PropertyTypeTests
|
||||
{
|
||||
[SetUp]
|
||||
public void SetUp() => _builder = new PropertyTypeBuilder();
|
||||
public void SetUp()
|
||||
{
|
||||
_propertyTypeBuilder = new PropertyTypeBuilder();
|
||||
_dataTypeBuilder = new DataTypeBuilder();
|
||||
}
|
||||
|
||||
private PropertyTypeBuilder _builder;
|
||||
private PropertyTypeBuilder _propertyTypeBuilder;
|
||||
private DataTypeBuilder _dataTypeBuilder;
|
||||
|
||||
[Test]
|
||||
public void Can_Create_From_DataType()
|
||||
{
|
||||
var shortStringHelper = new DefaultShortStringHelper(new DefaultShortStringHelperConfig());
|
||||
var dt = BuildDataType();
|
||||
var pt = new PropertyType(shortStringHelper, dt);
|
||||
|
||||
Assert.AreEqual(dt.Id, pt.DataTypeId);
|
||||
Assert.AreEqual(dt.Key, pt.DataTypeKey);
|
||||
Assert.AreEqual(dt.EditorAlias, pt.PropertyEditorAlias);
|
||||
Assert.AreEqual(dt.DatabaseType, pt.ValueStorageType);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Deep_Clone()
|
||||
@@ -32,7 +51,7 @@ public class PropertyTypeTests
|
||||
Assert.AreEqual(clone.Alias, pt.Alias);
|
||||
Assert.AreEqual(clone.CreateDate, pt.CreateDate);
|
||||
Assert.AreEqual(clone.DataTypeId, pt.DataTypeId);
|
||||
Assert.AreEqual(clone.DataTypeId, pt.DataTypeId);
|
||||
Assert.AreEqual(clone.DataTypeKey, pt.DataTypeKey);
|
||||
Assert.AreEqual(clone.Description, pt.Description);
|
||||
Assert.AreEqual(clone.Key, pt.Key);
|
||||
Assert.AreEqual(clone.Mandatory, pt.Mandatory);
|
||||
@@ -69,7 +88,7 @@ public class PropertyTypeTests
|
||||
}
|
||||
|
||||
private PropertyType BuildPropertyType() =>
|
||||
_builder
|
||||
_propertyTypeBuilder
|
||||
.WithId(3)
|
||||
.WithPropertyEditorAlias("TestPropertyEditor")
|
||||
.WithAlias("test")
|
||||
@@ -81,4 +100,8 @@ public class PropertyTypeTests
|
||||
.WithMandatory(true)
|
||||
.WithValidationRegExp("xxxx")
|
||||
.Build();
|
||||
|
||||
private DataType BuildDataType() =>
|
||||
_dataTypeBuilder
|
||||
.Build();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public class PropertyTypeBuilderTests
|
||||
const string testName = "Test";
|
||||
const int testSortOrder = 9;
|
||||
const int testDataTypeId = 5;
|
||||
var testDataTypeKey = Guid.NewGuid();
|
||||
var testCreateDate = DateTime.UtcNow.AddHours(-1);
|
||||
var testUpdateDate = DateTime.UtcNow;
|
||||
const string testDescription = "testing";
|
||||
@@ -43,6 +44,7 @@ public class PropertyTypeBuilderTests
|
||||
.WithName(testName)
|
||||
.WithSortOrder(testSortOrder)
|
||||
.WithDataTypeId(testDataTypeId)
|
||||
.WithDataTypeKey(testDataTypeKey)
|
||||
.WithCreateDate(testCreateDate)
|
||||
.WithUpdateDate(testUpdateDate)
|
||||
.WithDescription(testDescription)
|
||||
@@ -60,6 +62,7 @@ public class PropertyTypeBuilderTests
|
||||
Assert.AreEqual(testName, propertyType.Name);
|
||||
Assert.AreEqual(testSortOrder, propertyType.SortOrder);
|
||||
Assert.AreEqual(testDataTypeId, propertyType.DataTypeId);
|
||||
Assert.AreEqual(testDataTypeKey, propertyType.DataTypeKey);
|
||||
Assert.AreEqual(testCreateDate, propertyType.CreateDate);
|
||||
Assert.AreEqual(testUpdateDate, propertyType.UpdateDate);
|
||||
Assert.AreEqual(testDescription, propertyType.Description);
|
||||
|
||||
Reference in New Issue
Block a user