Files
Umbraco-CMS/tests/Umbraco.Tests.Common/Builders/DictionaryTranslationBuilder.cs
Nikolaj Geisle 7aeb400fce V10: fix build warnings in test projects (#12509)
* 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>
2022-06-21 08:09:38 +02:00

87 lines
2.3 KiB
C#

// Copyright (c) Umbraco.
// See LICENSE for more details.
using System;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Tests.Common.Builders.Interfaces;
namespace Umbraco.Cms.Tests.Common.Builders;
public class DictionaryTranslationBuilder
: ChildBuilderBase<DictionaryItemBuilder, IDictionaryTranslation>,
IWithIdBuilder,
IWithCreateDateBuilder,
IWithUpdateDateBuilder,
IWithDeleteDateBuilder,
IWithKeyBuilder
{
private readonly LanguageBuilder<DictionaryTranslationBuilder> _languageBuilder;
private DateTime? _createDate;
private DateTime? _deleteDate;
private int? _id;
private Guid? _key;
private DateTime? _updateDate;
private string _value;
public DictionaryTranslationBuilder()
: base(null) => _languageBuilder = new LanguageBuilder<DictionaryTranslationBuilder>(this);
public DictionaryTranslationBuilder(DictionaryItemBuilder parentBuilder)
: base(parentBuilder) => _languageBuilder = new LanguageBuilder<DictionaryTranslationBuilder>(this);
DateTime? IWithCreateDateBuilder.CreateDate
{
get => _createDate;
set => _createDate = value;
}
DateTime? IWithDeleteDateBuilder.DeleteDate
{
get => _deleteDate;
set => _deleteDate = value;
}
int? IWithIdBuilder.Id
{
get => _id;
set => _id = value;
}
Guid? IWithKeyBuilder.Key
{
get => _key;
set => _key = value;
}
DateTime? IWithUpdateDateBuilder.UpdateDate
{
get => _updateDate;
set => _updateDate = value;
}
public LanguageBuilder<DictionaryTranslationBuilder> AddLanguage() => _languageBuilder;
public DictionaryTranslationBuilder WithValue(string value)
{
_value = value;
return this;
}
public override IDictionaryTranslation Build()
{
var createDate = _createDate ?? DateTime.Now;
var updateDate = _updateDate ?? DateTime.Now;
var deleteDate = _deleteDate;
var id = _id ?? 1;
var key = _key ?? Guid.NewGuid();
var result = new DictionaryTranslation(
_languageBuilder.Build(),
_value ?? Guid.NewGuid().ToString(),
key)
{ CreateDate = createDate, UpdateDate = updateDate, DeleteDate = deleteDate, Id = id };
return result;
}
}