2020-12-05 11:12:55 +01:00
|
|
|
// Copyright (c) Umbraco.
|
|
|
|
|
// See LICENSE for more details.
|
|
|
|
|
|
2020-01-13 07:29:12 +01:00
|
|
|
using System;
|
|
|
|
|
using Moq;
|
2021-02-18 11:06:02 +01:00
|
|
|
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;
|
2020-01-13 07:29:12 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
namespace Umbraco.Cms.Tests.Common.Builders;
|
|
|
|
|
|
|
|
|
|
public class DataValueEditorBuilder<TParent> : ChildBuilderBase<TParent, IDataValueEditor>
|
2020-01-13 07:29:12 +01:00
|
|
|
{
|
2022-06-21 08:09:38 +02:00
|
|
|
private string _configuration;
|
|
|
|
|
private bool? _hideLabel;
|
|
|
|
|
private string _valueType;
|
|
|
|
|
private string _view;
|
|
|
|
|
|
|
|
|
|
public DataValueEditorBuilder(TParent parentBuilder)
|
|
|
|
|
: base(parentBuilder)
|
2020-01-13 07:29:12 +01:00
|
|
|
{
|
2022-06-21 08:09:38 +02:00
|
|
|
}
|
2020-01-13 07:29:12 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public DataValueEditorBuilder<TParent> WithConfiguration(string configuration)
|
|
|
|
|
{
|
|
|
|
|
_configuration = configuration;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2020-01-13 07:29:12 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public DataValueEditorBuilder<TParent> WithView(string view)
|
|
|
|
|
{
|
|
|
|
|
_view = view;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2020-01-13 07:29:12 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public DataValueEditorBuilder<TParent> WithHideLabel(bool hideLabel)
|
|
|
|
|
{
|
|
|
|
|
_hideLabel = hideLabel;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2020-01-13 07:29:12 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public DataValueEditorBuilder<TParent> WithValueType(string valueType)
|
|
|
|
|
{
|
|
|
|
|
_valueType = valueType;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2020-01-13 07:29:12 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public override IDataValueEditor Build()
|
|
|
|
|
{
|
|
|
|
|
var configuration = _configuration;
|
|
|
|
|
var valueType = _valueType ?? Guid.NewGuid().ToString();
|
2020-01-13 07:29:12 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
return new DataValueEditor(
|
|
|
|
|
Mock.Of<IShortStringHelper>(),
|
|
|
|
|
Mock.Of<IJsonSerializer>())
|
2020-01-13 07:29:12 +01:00
|
|
|
{
|
2023-04-25 15:32:29 +02:00
|
|
|
ConfigurationObject = configuration,
|
2022-06-21 08:09:38 +02:00
|
|
|
ValueType = valueType
|
|
|
|
|
};
|
2020-01-13 07:29:12 +01:00
|
|
|
}
|
|
|
|
|
}
|