* Persist and expose Umbraco system dates as UTC (#19705) * Updated persistence DTOs defining default dates to use UTC. * Remove ForceToUtc = false from all persistence DTO attributes (default when not specified is true). * Removed use of SpecifyKind setting dates to local. * Removed unnecessary Utc suffixes on properties. * Persist current date time with UtcNow. * Removed further necessary Utc suffixes and fixed failing unit tests. * Added migration for SQL server to update database date default constraints. * Added comment justifying not providing a migration for SQLite default date constraints. * Ensure UTC for datetimes created from persistence DTOs. * Ensure UTC when creating dates for published content rendering in Razor and outputting in delivery API. * Fixed migration SQL syntax. * Introduced AuditItemFactory for creating entries for the backoffice document history, so we can control the UTC setting on the retrieved persisted dates. * Ensured UTC dates are retrieved for document versions. * Ensured UTC is returned for backoffice display of last edited and published for variant content. * Fixed SQLite syntax for default current datetime. * Apply suggestions from code review Co-authored-by: Laura Neto <12862535+lauraneto@users.noreply.github.com> * Further updates from code review. --------- Co-authored-by: Laura Neto <12862535+lauraneto@users.noreply.github.com> * Migrate system dates from local server time to UTC (#19798) * Add settings for the migration. * Add migration and implement for SQL server. * Implement for SQLite. * Fixes from testing with SQL Server. * Fixes from testing with SQLite. * Code tidy. * Cleaned up usings. * Removed audit log date from conversion. * Removed webhook log date from conversion. * Updated update date initialization on saving dictionary items. * Updated filter on log queries. * Use timezone ID instead of system name to work cross-culture. --------- Co-authored-by: Laura Neto <12862535+lauraneto@users.noreply.github.com>
72 lines
2.6 KiB
C#
72 lines
2.6 KiB
C#
// Copyright (c) Umbraco.
|
|
// See LICENSE for more details.
|
|
|
|
using NUnit.Framework;
|
|
using Umbraco.Cms.Tests.Common.Builders;
|
|
using Umbraco.Cms.Tests.Common.Builders.Extensions;
|
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Tests.Common.Builders;
|
|
|
|
[TestFixture]
|
|
public class DocumentEntitySlimBuilderTests
|
|
{
|
|
[Test]
|
|
public void Is_Built_Correctly()
|
|
{
|
|
// Arrange
|
|
const int testId = 11;
|
|
const string testName = "Test";
|
|
const int testCreatorId = 22;
|
|
const int testLevel = 3;
|
|
const string testPath = "-1,23";
|
|
const int testParentId = 5;
|
|
const int testSortOrder = 6;
|
|
const bool testHasChildren = true;
|
|
const bool testPublished = true;
|
|
const string testContentTypeAlias = "test1";
|
|
const string testContentTypeIcon = "icon";
|
|
const string testContentTypeThumbnail = "thumb";
|
|
var testKey = Guid.NewGuid();
|
|
var testCreateDate = DateTime.UtcNow.AddHours(-1);
|
|
var testUpdateDate = DateTime.UtcNow;
|
|
|
|
var builder = new DocumentEntitySlimBuilder();
|
|
|
|
// Act
|
|
var item = builder
|
|
.WithId(testId)
|
|
.WithKey(testKey)
|
|
.WithCreatorId(testCreatorId)
|
|
.WithCreateDate(testCreateDate)
|
|
.WithUpdateDate(testUpdateDate)
|
|
.WithName(testName)
|
|
.WithParentId(testParentId)
|
|
.WithSortOrder(testSortOrder)
|
|
.WithLevel(testLevel)
|
|
.WithPath(testPath)
|
|
.WithContentTypeAlias(testContentTypeAlias)
|
|
.WithContentTypeIcon(testContentTypeIcon)
|
|
.WithContentTypeThumbnail(testContentTypeThumbnail)
|
|
.WithHasChildren(testHasChildren)
|
|
.WithPublished(testPublished)
|
|
.Build();
|
|
|
|
// Assert
|
|
Assert.AreEqual(testId, item.Id);
|
|
Assert.AreEqual(testKey, item.Key);
|
|
Assert.AreEqual(testName, item.Name);
|
|
Assert.AreEqual(testCreateDate, item.CreateDate);
|
|
Assert.AreEqual(testUpdateDate, item.UpdateDate);
|
|
Assert.AreEqual(testCreatorId, item.CreatorId);
|
|
Assert.AreEqual(testParentId, item.ParentId);
|
|
Assert.AreEqual(testSortOrder, item.SortOrder);
|
|
Assert.AreEqual(testPath, item.Path);
|
|
Assert.AreEqual(testLevel, item.Level);
|
|
Assert.AreEqual(testContentTypeAlias, item.ContentTypeAlias);
|
|
Assert.AreEqual(testContentTypeIcon, item.ContentTypeIcon);
|
|
Assert.AreEqual(testContentTypeThumbnail, item.ContentTypeThumbnail);
|
|
Assert.AreEqual(testHasChildren, item.HasChildren);
|
|
Assert.AreEqual(testPublished, item.Published);
|
|
}
|
|
}
|