* Run code cleanup * Dotnet format benchmarks project * Fix up Test.Common * Run dotnet format + manual cleanup * Run code cleanup for unit tests * Run dotnet format * Fix up errors * Manual cleanup of Unit test project * Update tests/Umbraco.Tests.Benchmarks/HexStringBenchmarks.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update tests/Umbraco.Tests.Integration/Testing/TestDbMeta.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update tests/Umbraco.Tests.Benchmarks/TypeFinderBenchmarks.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update tests/Umbraco.Tests.Integration/Umbraco.Core/Events/EventAggregatorTests.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Fix according to review * Fix after merge * Fix errors Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk> Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> Co-authored-by: Zeegaan <nge@umbraco.dk>
77 lines
2.0 KiB
C#
77 lines
2.0 KiB
C#
// Copyright (c) Umbraco.
|
|
// See LICENSE for more details.
|
|
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using Umbraco.Cms.Core.Models.ContentEditing;
|
|
using Umbraco.Cms.Tests.Common.Builders.Interfaces;
|
|
|
|
namespace Umbraco.Cms.Tests.Common.Builders;
|
|
|
|
public class ContentVariantSaveBuilder<TParent> : ChildBuilderBase<TParent, ContentVariantSave>,
|
|
IWithNameBuilder,
|
|
IWithCultureInfoBuilder
|
|
{
|
|
private readonly List<ContentPropertyBasicBuilder<ContentVariantSaveBuilder<TParent>>> _propertyBuilders = new();
|
|
private CultureInfo _cultureInfo;
|
|
|
|
private string _name;
|
|
private bool? _publish;
|
|
private bool? _save;
|
|
|
|
public ContentVariantSaveBuilder(TParent parentBuilder)
|
|
: base(parentBuilder)
|
|
{
|
|
}
|
|
|
|
CultureInfo IWithCultureInfoBuilder.CultureInfo
|
|
{
|
|
get => _cultureInfo;
|
|
set => _cultureInfo = value;
|
|
}
|
|
|
|
string IWithNameBuilder.Name
|
|
{
|
|
get => _name;
|
|
set => _name = value;
|
|
}
|
|
|
|
public ContentVariantSaveBuilder<TParent> WithSave(bool save)
|
|
{
|
|
_save = save;
|
|
return this;
|
|
}
|
|
|
|
public ContentVariantSaveBuilder<TParent> WithPublish(bool publish)
|
|
{
|
|
_publish = publish;
|
|
return this;
|
|
}
|
|
|
|
public ContentPropertyBasicBuilder<ContentVariantSaveBuilder<TParent>> AddProperty()
|
|
{
|
|
var builder = new ContentPropertyBasicBuilder<ContentVariantSaveBuilder<TParent>>(this);
|
|
_propertyBuilders.Add(builder);
|
|
return builder;
|
|
}
|
|
|
|
public override ContentVariantSave Build()
|
|
{
|
|
var name = _name;
|
|
var culture = _cultureInfo?.Name;
|
|
var save = _save ?? true;
|
|
var publish = _publish ?? true;
|
|
var properties = _propertyBuilders.Select(x => x.Build());
|
|
|
|
return new ContentVariantSave
|
|
{
|
|
Name = name,
|
|
Culture = culture,
|
|
Save = save,
|
|
Publish = publish,
|
|
Properties = properties
|
|
};
|
|
}
|
|
}
|