Files
Umbraco-CMS/tests/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs
Kenn Jacobsen aaf7075313 Property level validation for Management API (#15644)
* Property level validation for content - initial implementation

* Always succeed create/update regardless of property level validation errors

* Move old complex editor validation classes to Web.BackOffice so they will be deleted

* Include operation status and property validation errors in ProblemDetails

* Refactor property validation to its own service(s)

* Make the problem details builder a little more generic towards extensions

* Validation for item and branch publish

* Moved malplaced test

* Get rid of a TODO

* Integration tests for content validation service

* Simplify validation service

* Add missing response types to create and update for document and media

* Remove test that no longer applies

* Use "errors" for model validation errors (property validation errors)

* Split create/update and validation into their own endpoints

* Fix forward merge

* Correct wrong assumption for missing properties

* Remove localization from validation error messages - decreases dependencies, adds a lot of obsolete constructors

* Reuse existing validation service + support custom error messages

* Fix merge errors

* Review comments
2024-01-31 10:40:58 +01:00

68 lines
1.7 KiB
C#

// Copyright (c) Umbraco.
// See LICENSE for more details.
using System;
using Moq;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Strings;
namespace Umbraco.Cms.Tests.Common.Builders;
public class DataValueEditorBuilder<TParent> : ChildBuilderBase<TParent, IDataValueEditor>
{
private string _configuration;
private bool? _hideLabel;
private string _valueType;
private string _view;
public DataValueEditorBuilder(TParent parentBuilder)
: base(parentBuilder)
{
}
public DataValueEditorBuilder<TParent> WithConfiguration(string configuration)
{
_configuration = configuration;
return this;
}
public DataValueEditorBuilder<TParent> WithView(string view)
{
_view = view;
return this;
}
public DataValueEditorBuilder<TParent> WithHideLabel(bool hideLabel)
{
_hideLabel = hideLabel;
return this;
}
public DataValueEditorBuilder<TParent> WithValueType(string valueType)
{
_valueType = valueType;
return this;
}
public override IDataValueEditor Build()
{
var configuration = _configuration;
var view = _view;
var hideLabel = _hideLabel ?? false;
var valueType = _valueType ?? Guid.NewGuid().ToString();
return new DataValueEditor(
Mock.Of<IShortStringHelper>(),
Mock.Of<IJsonSerializer>())
{
ConfigurationObject = configuration,
View = view,
HideLabel = hideLabel,
ValueType = valueType
};
}
}