2020-12-05 11:12:55 +01:00
|
|
|
// Copyright (c) Umbraco.
|
|
|
|
|
// See LICENSE for more details.
|
|
|
|
|
|
2020-01-09 14:24:20 +01:00
|
|
|
using System;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.Models;
|
|
|
|
|
using Umbraco.Cms.Tests.Common.Builders.Interfaces;
|
2020-01-09 14:24:20 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
namespace Umbraco.Cms.Tests.Common.Builders;
|
|
|
|
|
|
|
|
|
|
public class DictionaryTranslationBuilder
|
|
|
|
|
: ChildBuilderBase<DictionaryItemBuilder, IDictionaryTranslation>,
|
|
|
|
|
IWithIdBuilder,
|
|
|
|
|
IWithCreateDateBuilder,
|
|
|
|
|
IWithUpdateDateBuilder,
|
|
|
|
|
IWithDeleteDateBuilder,
|
|
|
|
|
IWithKeyBuilder
|
2020-01-09 14:24:20 +01:00
|
|
|
{
|
2022-06-21 08:09:38 +02:00
|
|
|
private readonly LanguageBuilder<DictionaryTranslationBuilder> _languageBuilder;
|
|
|
|
|
private DateTime? _createDate;
|
|
|
|
|
private DateTime? _deleteDate;
|
|
|
|
|
private int? _id;
|
|
|
|
|
private Guid? _key;
|
|
|
|
|
private DateTime? _updateDate;
|
|
|
|
|
private string _value;
|
2020-01-09 14:24:20 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public DictionaryTranslationBuilder()
|
|
|
|
|
: base(null) => _languageBuilder = new LanguageBuilder<DictionaryTranslationBuilder>(this);
|
2020-04-19 09:39:30 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public DictionaryTranslationBuilder(DictionaryItemBuilder parentBuilder)
|
|
|
|
|
: base(parentBuilder) => _languageBuilder = new LanguageBuilder<DictionaryTranslationBuilder>(this);
|
2020-01-09 14:24:20 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
DateTime? IWithCreateDateBuilder.CreateDate
|
|
|
|
|
{
|
|
|
|
|
get => _createDate;
|
|
|
|
|
set => _createDate = value;
|
|
|
|
|
}
|
2020-04-12 09:47:44 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
DateTime? IWithDeleteDateBuilder.DeleteDate
|
|
|
|
|
{
|
|
|
|
|
get => _deleteDate;
|
|
|
|
|
set => _deleteDate = value;
|
|
|
|
|
}
|
2020-04-12 09:47:44 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
int? IWithIdBuilder.Id
|
|
|
|
|
{
|
|
|
|
|
get => _id;
|
|
|
|
|
set => _id = value;
|
|
|
|
|
}
|
2020-04-12 09:47:44 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
Guid? IWithKeyBuilder.Key
|
|
|
|
|
{
|
|
|
|
|
get => _key;
|
|
|
|
|
set => _key = value;
|
|
|
|
|
}
|
2020-04-12 09:47:44 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
DateTime? IWithUpdateDateBuilder.UpdateDate
|
|
|
|
|
{
|
|
|
|
|
get => _updateDate;
|
|
|
|
|
set => _updateDate = value;
|
|
|
|
|
}
|
2020-04-12 09:47:44 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public LanguageBuilder<DictionaryTranslationBuilder> AddLanguage() => _languageBuilder;
|
2020-01-09 14:24:20 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public DictionaryTranslationBuilder WithValue(string value)
|
|
|
|
|
{
|
|
|
|
|
_value = value;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2020-01-09 14:24:20 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public override IDictionaryTranslation Build()
|
|
|
|
|
{
|
2025-08-22 11:59:23 +02:00
|
|
|
var createDate = _createDate ?? DateTime.UtcNow;
|
|
|
|
|
var updateDate = _updateDate ?? DateTime.UtcNow;
|
2022-06-21 08:09:38 +02:00
|
|
|
var deleteDate = _deleteDate;
|
|
|
|
|
var id = _id ?? 1;
|
|
|
|
|
var key = _key ?? Guid.NewGuid();
|
2020-01-09 14:24:20 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
var result = new DictionaryTranslation(
|
|
|
|
|
_languageBuilder.Build(),
|
|
|
|
|
_value ?? Guid.NewGuid().ToString(),
|
|
|
|
|
key)
|
|
|
|
|
{ CreateDate = createDate, UpdateDate = updateDate, DeleteDate = deleteDate, Id = id };
|
2020-01-09 14:24:20 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
return result;
|
2020-01-09 14:24:20 +01:00
|
|
|
}
|
|
|
|
|
}
|