Files
Umbraco-CMS/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/NotificationsRepositoryTest.cs

284 lines
10 KiB
C#
Raw Normal View History

// Copyright (c) Umbraco.
// See LICENSE for more details.
using System.Globalization;
using System.Linq;
using Moq;
using NUnit.Framework;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Models.Membership;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement;
2022-01-13 17:44:11 +00:00
using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Testing;
namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories;
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
Remove the non-controversial, straightforward obsoleted constructs for Umbraco 16 (#18661) * Removed obsoletes from IConfigManipulator. * Removed obsolete models builder extensions. * Removed the obsolete ContentDashboardSettings. * Removed the obsolete InstallMissingDatabase setting on GlobalSettings. * Removed obsolete NuCache settings. * Removed obsolete RuntimeMinificationSettings. * Removed obsolete health check constant. * Removed obsolete icon constant. * Removed obsolete telemetry constant. * Removed obsolete property and constructor on UmbracoBuilder. * Removed obsolete constructor on AuditNotificationsHandler. * Removed obsolete constructor on HTTP header health checks. * Removed obsolete constructor on MediaFileManager. * Removed obsolete GetDefaultFileContent on ViewHelper. * Remove obsoleted methods on embed providers. * Fix tests. * Removed obsolete constructors on BlockEditorDataConverter. * Removed obsolete SeedCacheDuration property on CacheSettings. * Removed obsolete PublishCulture on ContentRepositoryExtensions. * Removed obsolete MonitorLock. * Removed obsolete synchronous HasSavedValues from IDataTypeUsageService and IDataTypeUsageRepository. * Removed obsolete HasSavedPropertyValues from IPropertyTypeUsageService and IPropertyTypeUsageRepository. * Removed obsolete methods in ITrackedReferencesService and ITrackedReferencesRepository. * Removed obsolete DateValueEditor constructors. * Removed obsolete GetAutomaticRelationTypesAliases. * Removed obsolete constructor on TextOnlyValueEditor. * Removed obsolete constructors on RegexValidator and RequiredValidator. * Removed obsolete constructs on SliderValueConverter and TagsValueConverter. * Removed obsolete GetContentType methods from IPublishedCache. * Removed ContentFinderByIdPath. * Removed obsolete constructor on DefaultMediaUrlProvider. * Removed obsolete constructor on Domain. * Removed obsolete constructor on PublishedRequest. * Removed obsolete methods on CheckPermissions. * Removed obsolete GetUserId from IBackOfficeSecurity. * Removed obsolete methods on LegacyPasswordSecurity. * Removed obsolete constructors on AuditService. * Removed obsolete methods on IContentEditingService. * Remove obsolete constructors and methods on ContentService/IContentService. * Removed obsolete constructor in ContentTypeEditingService. * Removed obsolete constructor in MediaTypeEditingService. * Removed obsolete constructor in MemberTypeEditingService. * Removed obsolete constructor in ContentTypeService. * Removed obsolete constructors in ContentTypeServiceBase. * Removed obsolete constructors and methods in ContentVersionService. * Removed obsolete constructor in DataTypeUsageService. * Removed obsolete constructor in DomainService. * Removed obsolete constructor in FileService. * Removes obsolete AttemptMove from IContentService. * Removes obsolete SetPreventCleanup from IContentVersionService. * Removes obsolete GetReferences from IDataTypeService. * Removed obsolete SetConsentLevel from IMetricsConsentService. * Removed obsolete methods from IPackageDataInstallation. * Removed obsolete methods from IPackagingService. * Removed obsolete methods on ITwoFactorLoginService. Removed obsolete ITemporaryMediaService. * Removed obsolete constructor from MediaService, MemberTypeService and MediaTypeService. * More obsolete constructors. * Removed obsoleted overloads on IPropertyValidationService. * Fixed build for tests. * Removed obsolete constructor for PublicAccessService, UserService and RelationService. * Removed GetDefaultMemberType. * Removed obsolete user group functionality from IUserService. * Removed obsolete extension methods on IUserService. * Removed obsolete method from ITelemetryService. * Removed obsolete UdiParserServiceConnectors. * Removed obsolete method on ICookieManager. * Removed obsolete DynamicContext. * Removed obsolete XmlHelper. * Fixed failing integration tests. * Removed obsoletes in Umbraco.Cms.Api.Common * Removed obsoletes in Umbraco.Cms.Api.Delivery * Removed obsoletes in Umbraco.Cms.Api.Management * Removed obsoletes in Umbraco.Examine.Lucene * Removed obsoletes in Umbraco.Infrastructure * Fix failing delivery API contract integration test. * Made integration tests internal. * Removed obsoletes from web projects. * Fix build. * Removed Twitter OEmbed provider * Removed obsolete constructor on PublishedDataType. * Removed obsolete constructors on PublishedCacheBase. * Removed the obsolete PropertyEditorTagsExtensions. * Removed obsoletion properties on configuration response models (#18697) * Removed obsolete methods from server-side models. * Update client-side types and sdk. * Update client-side files. * Removed obsoletion of Utf8ToAsciiConverter.ToAsciiString overload. (#18694) * Removed obsolete method in UserService. (#18710) * Removed obsoleted group alias keys from being publicly available. (#18682) * Removed unneceessary ApiVersion attribute. * Clean-up obsoletions on MemberService (#18703) * Removed obsoleted method on MemberService, added future obsoletion to interface and updated all callers. * Removed obsoletion on member service method that's not obsolete on the interface.
2025-03-21 18:02:31 +01:00
internal sealed class NotificationsRepositoryTest : UmbracoIntegrationTest
{
[Test]
public void CreateNotification()
{
var provider = ScopeProvider;
using (var scope = provider.CreateScope())
{
var repo = new NotificationsRepository((IScopeAccessor)provider);
var node = new NodeDto // create bogus item so we can add a notification
{
Use UTC for system dates in Umbraco (#19822) * 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>
2025-08-22 11:59:23 +02:00
CreateDate = DateTime.UtcNow,
Level = 1,
NodeObjectType = Constants.ObjectTypes.ContentItem,
ParentId = -1,
Path = "-1,123",
SortOrder = 1,
Text = "hello",
Trashed = false,
UniqueId = Guid.NewGuid(),
UserId = Constants.Security.SuperUserId
};
var result = ScopeAccessor.AmbientScope.Database.Insert(node);
var entity = Mock.Of<IEntity>(e => e.Id == node.NodeId);
var user = Mock.Of<IUser>(e => e.Id == node.UserId);
repo.TryCreateNotification(user, entity, "A", out Notification? notification);
Assert.IsNotNull(notification);
Assert.AreEqual("A", notification.Action);
Assert.AreEqual(node.NodeId, notification.EntityId);
Assert.AreEqual(node.NodeObjectType, notification.EntityType);
Assert.AreEqual(node.UserId, notification.UserId);
}
}
[Test]
public void GetUserNotifications()
{
var provider = ScopeProvider;
using (var scope = provider.CreateScope())
{
var repo = new NotificationsRepository((IScopeAccessor)provider);
var userDto = new UserDto
{
Email = "test",
Login = "test",
Password = "test",
UserName = "test",
UserLanguage = "en",
Use UTC for system dates in Umbraco (#19822) * 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>
2025-08-22 11:59:23 +02:00
CreateDate = DateTime.UtcNow,
UpdateDate = DateTime.UtcNow,
};
ScopeAccessor.AmbientScope.Database.Insert(userDto);
var userNew = Mock.Of<IUser>(e => e.Id == userDto.Id);
var userAdmin = Mock.Of<IUser>(e => e.Id == Constants.Security.SuperUserId);
for (var i = 0; i < 10; i++)
{
var node = new NodeDto
2018-03-19 13:36:31 +01:00
{
Use UTC for system dates in Umbraco (#19822) * 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>
2025-08-22 11:59:23 +02:00
CreateDate = DateTime.UtcNow,
2018-03-19 13:36:31 +01:00
Level = 1,
NodeObjectType = Constants.ObjectTypes.ContentItem,
ParentId = -1,
Path = "-1," + i,
2018-03-19 13:36:31 +01:00
SortOrder = 1,
Text = "hello" + i,
2018-03-19 13:36:31 +01:00
Trashed = false,
UniqueId = Guid.NewGuid(),
UserId = -1
2018-03-19 13:36:31 +01:00
};
var result = ScopeAccessor.AmbientScope.Database.Insert(node);
var entity = Mock.Of<IEntity>(e => e.Id == node.NodeId);
repo.TryCreateNotification(i % 2 == 0 ? userAdmin : userNew, entity, i.ToString(CultureInfo.InvariantCulture), out Notification? notification);
}
var notifications = repo.GetUserNotifications(userAdmin);
Assert.AreEqual(5, notifications.Count());
}
}
[Test]
public void GetEntityNotifications()
{
var provider = ScopeProvider;
using (var scope = provider.CreateScope())
{
var repo = new NotificationsRepository((IScopeAccessor)provider);
var node1 = new NodeDto
{
Use UTC for system dates in Umbraco (#19822) * 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>
2025-08-22 11:59:23 +02:00
CreateDate = DateTime.UtcNow,
Level = 1,
NodeObjectType = Constants.ObjectTypes.ContentItem,
ParentId = -1,
Path = "-1,1",
SortOrder = 1,
Text = "hello1",
Trashed = false,
UniqueId = Guid.NewGuid(),
UserId = -1
};
ScopeAccessor.AmbientScope.Database.Insert(node1);
var entity1 = Mock.Of<IEntity>(e => e.Id == node1.NodeId);
var node2 = new NodeDto
{
Use UTC for system dates in Umbraco (#19822) * 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>
2025-08-22 11:59:23 +02:00
CreateDate = DateTime.UtcNow,
Level = 1,
NodeObjectType = Constants.ObjectTypes.ContentItem,
ParentId = -1,
Path = "-1,2",
SortOrder = 1,
Text = "hello2",
Trashed = false,
UniqueId = Guid.NewGuid(),
UserId = -1
};
ScopeAccessor.AmbientScope.Database.Insert(node2);
var entity2 = Mock.Of<IEntity>(e => e.Id == node2.NodeId);
for (var i = 0; i < 10; i++)
{
var userDto = new UserDto
{
Key = Guid.NewGuid(),
Email = "test" + i,
Login = "test" + i,
Password = "test",
UserName = "test" + i,
UserLanguage = "en",
Use UTC for system dates in Umbraco (#19822) * 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>
2025-08-22 11:59:23 +02:00
CreateDate = DateTime.UtcNow,
UpdateDate = DateTime.UtcNow
};
ScopeAccessor.AmbientScope.Database.Insert(userDto);
var userNew = Mock.Of<IUser>(e => e.Id == userDto.Id);
repo.TryCreateNotification(userNew, i % 2 == 0 ? entity1 : entity2, i.ToString(CultureInfo.InvariantCulture), out Notification? notification);
}
var notifications = repo.GetEntityNotifications(entity1);
Assert.AreEqual(5, notifications.Count());
}
}
[Test]
public void Delete_By_Entity()
{
var provider = ScopeProvider;
using (var scope = provider.CreateScope())
{
var repo = new NotificationsRepository((IScopeAccessor)provider);
var node1 = new NodeDto
{
Use UTC for system dates in Umbraco (#19822) * 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>
2025-08-22 11:59:23 +02:00
CreateDate = DateTime.UtcNow,
Level = 1,
NodeObjectType = Constants.ObjectTypes.ContentItem,
ParentId = -1,
Path = "-1,1",
SortOrder = 1,
Text = "hello1",
Trashed = false,
UniqueId = Guid.NewGuid(),
UserId = -1
};
ScopeAccessor.AmbientScope.Database.Insert(node1);
var entity1 = Mock.Of<IEntity>(e => e.Id == node1.NodeId);
var node2 = new NodeDto
{
Use UTC for system dates in Umbraco (#19822) * 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>
2025-08-22 11:59:23 +02:00
CreateDate = DateTime.UtcNow,
Level = 1,
NodeObjectType = Constants.ObjectTypes.ContentItem,
ParentId = -1,
Path = "-1,2",
SortOrder = 1,
Text = "hello2",
Trashed = false,
UniqueId = Guid.NewGuid(),
UserId = -1
};
ScopeAccessor.AmbientScope.Database.Insert(node2);
var entity2 = Mock.Of<IEntity>(e => e.Id == node2.NodeId);
for (var i = 0; i < 10; i++)
{
var userDto = new UserDto
{
Key = Guid.NewGuid(),
Email = "test" + i,
Login = "test" + i,
Password = "test",
UserName = "test" + i,
UserLanguage = "en",
Use UTC for system dates in Umbraco (#19822) * 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>
2025-08-22 11:59:23 +02:00
CreateDate = DateTime.UtcNow,
UpdateDate = DateTime.UtcNow
};
ScopeAccessor.AmbientScope.Database.Insert(userDto);
var userNew = Mock.Of<IUser>(e => e.Id == userDto.Id);
repo.TryCreateNotification(userNew, i % 2 == 0 ? entity1 : entity2, i.ToString(CultureInfo.InvariantCulture), out Notification? notification);
}
var delCount = repo.DeleteNotifications(entity1);
Assert.AreEqual(5, delCount);
}
}
[Test]
public void Delete_By_User()
{
var provider = ScopeProvider;
using (var scope = provider.CreateScope())
{
var repo = new NotificationsRepository((IScopeAccessor)provider);
var userDto = new UserDto
{
Email = "test",
Login = "test",
Password = "test",
UserName = "test",
UserLanguage = "en",
Use UTC for system dates in Umbraco (#19822) * 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>
2025-08-22 11:59:23 +02:00
CreateDate = DateTime.UtcNow,
UpdateDate = DateTime.UtcNow
};
ScopeAccessor.AmbientScope.Database.Insert(userDto);
var userNew = Mock.Of<IUser>(e => e.Id == userDto.Id);
var userAdmin = Mock.Of<IUser>(e => e.Id == Constants.Security.SuperUserId);
for (var i = 0; i < 10; i++)
{
var node = new NodeDto
{
Use UTC for system dates in Umbraco (#19822) * 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>
2025-08-22 11:59:23 +02:00
CreateDate = DateTime.UtcNow,
Level = 1,
NodeObjectType = Constants.ObjectTypes.ContentItem,
ParentId = -1,
Path = "-1," + i,
SortOrder = 1,
Text = "hello" + i,
Trashed = false,
UniqueId = Guid.NewGuid(),
UserId = -1
};
var result = ScopeAccessor.AmbientScope.Database.Insert(node);
var entity = Mock.Of<IEntity>(e => e.Id == node.NodeId);
repo.TryCreateNotification(i % 2 == 0 ? userAdmin : userNew, entity, i.ToString(CultureInfo.InvariantCulture), out Notification? notification);
}
var delCount = repo.DeleteNotifications(userAdmin);
Assert.AreEqual(5, delCount);
}
}
2017-07-20 11:21:28 +02:00
}