Files
Umbraco-CMS/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/EntityXmlSerializerTests.cs

312 lines
14 KiB
C#
Raw Permalink Normal View History

// Copyright (c) Umbraco.
// See LICENSE for more details.
using System.Collections.Generic;
using System.Diagnostics;
using System.Xml.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Moq;
using NUnit.Framework;
using Umbraco.Cms.Core;
Add support for file upload property editor within the block list and grid (#18976) * Fix for https://github.com/umbraco/Umbraco-CMS/issues/18872 * Parsing added for current value * Build fix. * Cyclomatic complexity fix * Resolved breaking change. * Pass content key. * Simplified collections. * Added unit tests to verify behaviour. * Allow file upload on block list. * Added unit test verifying added property. * Added unit test verifying removed property. * Restored null return for null value fixing failing integration tests. * Logic has been updated according edge cases * Logic to copy files from block list items has been added. * Logic to delete files from block list items on content deletion has been added * Test fix. * Refactoring. * WIP: Resolved breaking changes, minor refactoring. * Consistently return null over empty, resolving failure in integration test. * Removed unnecessary code nesting. * Handle distinct paths. * Handles clean up of files added via file upload in rich text blocks on delete of the content. * Update src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs Co-authored-by: Sven Geusens <geusens@gmail.com> * Fixed build of integration tests project. * Handled delete of file uploads when deleting a block from an RTE using a file upload property. * Refactored ensure of property type property populated on rich text values to a common helper extension method. * Fixed integration tests build. * Handle create of new file from file upload block in an RTE when the document is copied. * Fixed failing integration tests. * Refactored notification handlers relating to file uploads into separate classes. * Handle nested rich text editor block with file upload when copying content. * Handle nested rich text editor block with file upload when deleting content. * Minor refactor. * Integration test compatibility supressions. --------- Co-authored-by: Andy Butland <abutland73@gmail.com> Co-authored-by: Sven Geusens <geusens@gmail.com>
2025-06-30 14:21:10 +03:00
using Umbraco.Cms.Core.Cache.PropertyEditors;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Media;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Persistence.Repositories;
using Umbraco.Cms.Core.PropertyEditors;
Add support for file upload property editor within the block list and grid (#18976) * Fix for https://github.com/umbraco/Umbraco-CMS/issues/18872 * Parsing added for current value * Build fix. * Cyclomatic complexity fix * Resolved breaking change. * Pass content key. * Simplified collections. * Added unit tests to verify behaviour. * Allow file upload on block list. * Added unit test verifying added property. * Added unit test verifying removed property. * Restored null return for null value fixing failing integration tests. * Logic has been updated according edge cases * Logic to copy files from block list items has been added. * Logic to delete files from block list items on content deletion has been added * Test fix. * Refactoring. * WIP: Resolved breaking changes, minor refactoring. * Consistently return null over empty, resolving failure in integration test. * Removed unnecessary code nesting. * Handle distinct paths. * Handles clean up of files added via file upload in rich text blocks on delete of the content. * Update src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs Co-authored-by: Sven Geusens <geusens@gmail.com> * Fixed build of integration tests project. * Handled delete of file uploads when deleting a block from an RTE using a file upload property. * Refactored ensure of property type property populated on rich text values to a common helper extension method. * Fixed integration tests build. * Handle create of new file from file upload block in an RTE when the document is copied. * Fixed failing integration tests. * Refactored notification handlers relating to file uploads into separate classes. * Handle nested rich text editor block with file upload when copying content. * Handle nested rich text editor block with file upload when deleting content. * Minor refactor. * Integration test compatibility supressions. --------- Co-authored-by: Andy Butland <abutland73@gmail.com> Co-authored-by: Sven Geusens <geusens@gmail.com>
2025-06-30 14:21:10 +03:00
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Tests.Common.Builders;
using Umbraco.Cms.Tests.Common.Builders.Extensions;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Testing;
using Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services.Importing;
namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services;
[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 EntityXmlSerializerTests : UmbracoIntegrationTest
{
private IEntityXmlSerializer Serializer => GetRequiredService<IEntityXmlSerializer>();
private IContentService ContentService => GetRequiredService<IContentService>();
private IMediaService MediaService => GetRequiredService<IMediaService>();
private IUserService UserService => GetRequiredService<IUserService>();
private IMediaTypeService MediaTypeService => GetRequiredService<IMediaTypeService>();
private IContentTypeService ContentTypeService => GetRequiredService<IContentTypeService>();
private IDataValueEditorFactory DataValueEditorFactory => GetRequiredService<IDataValueEditorFactory>();
private ILocalizedTextService TextService => GetRequiredService<ILocalizedTextService>();
private IFileService FileService => GetRequiredService<IFileService>();
[Test]
public async Task Can_Export_DictionaryItems()
{
// Arrange
await CreateDictionaryData();
var localizationService = GetRequiredService<ILocalizationService>();
var dictionaryItem = localizationService.GetDictionaryItemByKey("Parent");
var newPackageXml = XElement.Parse(ImportResources.Dictionary_Package);
var dictionaryItemsElement = newPackageXml.Elements("DictionaryItems").First();
// Act
var xml = Serializer.Serialize(new[] { dictionaryItem });
// Assert
Assert.That(xml.ToString(), Is.EqualTo(dictionaryItemsElement.ToString()));
}
[Test]
public async Task Can_Export_Languages()
{
// Arrange
var languageService = GetRequiredService<ILanguageService>();
var languageNbNo = new LanguageBuilder()
.WithCultureInfo("nb-NO")
.WithCultureName("Norwegian Bokmål (Norway)")
.Build();
await languageService.CreateAsync(languageNbNo, Constants.Security.SuperUserKey);
var languageEnGb = new LanguageBuilder()
.WithCultureInfo("en-GB")
.Build();
await languageService.CreateAsync(languageEnGb, Constants.Security.SuperUserKey);
var newPackageXml = XElement.Parse(ImportResources.Dictionary_Package);
var languageItemsElement = newPackageXml.Elements("Languages").First();
// Act
var xml = Serializer.Serialize(new[] { languageNbNo, languageEnGb });
// Assert
Assert.That(xml.ToString(), Is.EqualTo(languageItemsElement.ToString()));
}
[Test]
public void Can_Generate_Xml_Representation_Of_Content()
{
// Arrange
var template = TemplateBuilder.CreateTextPageTemplate();
FileService.SaveTemplate(template); // else, FK violation on contentType!
var contentType = ContentTypeBuilder.CreateTextPageContentType(
defaultTemplateId: template.Id);
ContentTypeService.Save(contentType);
var content = ContentBuilder.CreateTextpageContent(contentType, "Root Home", -1);
ContentService.Save(content, Constants.Security.SuperUserId);
var nodeName = content.ContentType.Alias.ToSafeAlias(ShortStringHelper);
var urlName =
content.GetUrlSegment(ShortStringHelper, new[] { new DefaultUrlSegmentProvider(ShortStringHelper) });
// Act
var element = content.ToXml(Serializer);
// Assert
Assert.That(element, Is.Not.Null);
Assert.That(element.Name.LocalName, Is.EqualTo(nodeName));
Assert.AreEqual(content.Id.ToString(), (string)element.Attribute("id"));
Assert.AreEqual(content.ParentId.ToString(), (string)element.Attribute("parentID"));
Assert.AreEqual(content.Level.ToString(), (string)element.Attribute("level"));
Assert.AreEqual(content.CreatorId.ToString(), (string)element.Attribute("creatorID"));
Assert.AreEqual(content.SortOrder.ToString(), (string)element.Attribute("sortOrder"));
Assert.AreEqual(content.CreateDate.ToString("s"), (string)element.Attribute("createDate"));
Assert.AreEqual(content.UpdateDate.ToString("s"), (string)element.Attribute("updateDate"));
Assert.AreEqual(content.Name, (string)element.Attribute("nodeName"));
Assert.AreEqual(urlName, (string)element.Attribute("urlName"));
Assert.AreEqual(content.Path, (string)element.Attribute("path"));
Resolved more warnings, and marked more warning types as errors (#16991) * Fix warnings SA1111, SA1028, SA1500, IDE1270 in Umbraco.Web.Website, and updated rules. * Remove warnings: IDE0270: Null check can be simplified * More SqlServer project warnings resolved * CS0105 namespace appeared already * Suppress warning until implementation: #pragma warning disable CS0162 // Unreachable code detected #pragma warning disable CS0618 // Type or member is obsolete CS0162 remove unreachable code SA1028 remove trailing whitespace SA1106 no empty statements CS1570 malformed XML CS1572 corrected xml parameter CS1573 param tag added IDE0007 var not explicit IDE0008 explicit not var IDE0057 simplify substring IDE0074 compound assignment CA1825 array.empty Down to 3479 warnings * - SA1116, SA117 params on same line - IDE0057 substring simplified Specific warnings for Umbraco.Tests.Benchmarks * Fixed IDE0074 compound assignment and added specific warnings for Umbraco.Tests.Common * Specific warnings for Umbraco.Tests.Integration and Umbraco.Tests.Common Fixed: - SA1111, SA1116, SA117 params and line formatting (not all as there are many) - SA1122 string.Empty - IDE0057 simplify substring - IDE0044,IDE0044 make field readonly - IDE1006 naming rule violation (add _) - SA1111 closing parenthesis on line of last parameter - SA1649 filename match type name - SA1312,SA1306 lowercase variable and field names * Fixed various warnings where they are more straight-forward, including: - SA1649 file name match type name - SA111 parenthesis on line of last parameter - IDE0028 simplify collection initializer - SA1306 lower-case letter field - IDE044 readonly field - SA1122 string.Empty - SA1116 params same line - IDE1006 upper casing - IDE0041 simplify null check Updated the following projects to only list their remaining specific warning codes: - Umbraco.Tests.UnitTests Typo in `Umbraco.Web.Website` project * Reverted test change * Now 1556 warnings. Fixed various warnings where they are more straight-forward, including: - SA1111/SA1116/SA1119 parenthesis - SA1117 params - SA1312 lowercase variable - SA1121 built-in type - SA1500/SA1513/SA1503 formatting braces - SA1400 declare access modifier - SA1122 string.Empty - SA1310 no underscore - IDE0049 name simplified - IDE0057 simplify substring - IDE0074 compound assignment - IDE0032 use auto-property - IDE0037 simplify member name - IDE0008 explicit type not var - IDE0016/IDE0270/IDE0041 simplify null checks - IDE0048/SA1407 clarity in arithmetic - IDE1006 correct param names - IDE0042 deconstruct variable - IDE0044 readonly - IDE0018 inline variable declarations - IDE0074/IDE0054 compound assignment - IDE1006 naming - CS1573 param XML - CS0168 unused variable Comment formatting in project files for consistency. Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default). * Type not var, and more warning exceptions * Tweaked merge issue, readded comment about rollback * Readded comment re rollback. * Readded comments * Comment tweak * Comment tweak
2024-09-24 12:56:28 +01:00
Assert.AreEqual(string.Empty, (string)element.Attribute("isDoc"));
Assert.AreEqual(content.ContentType.Id.ToString(), (string)element.Attribute("nodeType"));
Assert.AreEqual(content.GetCreatorProfile(UserService).Name, (string)element.Attribute("creatorName"));
Assert.AreEqual(content.GetWriterProfile(UserService).Name, (string)element.Attribute("writerName"));
Assert.AreEqual(content.WriterId.ToString(), (string)element.Attribute("writerID"));
Assert.AreEqual(content.TemplateId.ToString(), (string)element.Attribute("template"));
Assert.AreEqual(content.Properties["title"].GetValue().ToString(), element.Elements("title").Single().Value);
Resolved more warnings, and marked more warning types as errors (#16991) * Fix warnings SA1111, SA1028, SA1500, IDE1270 in Umbraco.Web.Website, and updated rules. * Remove warnings: IDE0270: Null check can be simplified * More SqlServer project warnings resolved * CS0105 namespace appeared already * Suppress warning until implementation: #pragma warning disable CS0162 // Unreachable code detected #pragma warning disable CS0618 // Type or member is obsolete CS0162 remove unreachable code SA1028 remove trailing whitespace SA1106 no empty statements CS1570 malformed XML CS1572 corrected xml parameter CS1573 param tag added IDE0007 var not explicit IDE0008 explicit not var IDE0057 simplify substring IDE0074 compound assignment CA1825 array.empty Down to 3479 warnings * - SA1116, SA117 params on same line - IDE0057 substring simplified Specific warnings for Umbraco.Tests.Benchmarks * Fixed IDE0074 compound assignment and added specific warnings for Umbraco.Tests.Common * Specific warnings for Umbraco.Tests.Integration and Umbraco.Tests.Common Fixed: - SA1111, SA1116, SA117 params and line formatting (not all as there are many) - SA1122 string.Empty - IDE0057 simplify substring - IDE0044,IDE0044 make field readonly - IDE1006 naming rule violation (add _) - SA1111 closing parenthesis on line of last parameter - SA1649 filename match type name - SA1312,SA1306 lowercase variable and field names * Fixed various warnings where they are more straight-forward, including: - SA1649 file name match type name - SA111 parenthesis on line of last parameter - IDE0028 simplify collection initializer - SA1306 lower-case letter field - IDE044 readonly field - SA1122 string.Empty - SA1116 params same line - IDE1006 upper casing - IDE0041 simplify null check Updated the following projects to only list their remaining specific warning codes: - Umbraco.Tests.UnitTests Typo in `Umbraco.Web.Website` project * Reverted test change * Now 1556 warnings. Fixed various warnings where they are more straight-forward, including: - SA1111/SA1116/SA1119 parenthesis - SA1117 params - SA1312 lowercase variable - SA1121 built-in type - SA1500/SA1513/SA1503 formatting braces - SA1400 declare access modifier - SA1122 string.Empty - SA1310 no underscore - IDE0049 name simplified - IDE0057 simplify substring - IDE0074 compound assignment - IDE0032 use auto-property - IDE0037 simplify member name - IDE0008 explicit type not var - IDE0016/IDE0270/IDE0041 simplify null checks - IDE0048/SA1407 clarity in arithmetic - IDE1006 correct param names - IDE0042 deconstruct variable - IDE0044 readonly - IDE0018 inline variable declarations - IDE0074/IDE0054 compound assignment - IDE1006 naming - CS1573 param XML - CS0168 unused variable Comment formatting in project files for consistency. Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default). * Type not var, and more warning exceptions * Tweaked merge issue, readded comment about rollback * Readded comment re rollback. * Readded comments * Comment tweak * Comment tweak
2024-09-24 12:56:28 +01:00
Assert.AreEqual(
content.Properties["bodyText"].GetValue().ToString(),
element.Elements("bodyText").Single().Value);
Resolved more warnings, and marked more warning types as errors (#16991) * Fix warnings SA1111, SA1028, SA1500, IDE1270 in Umbraco.Web.Website, and updated rules. * Remove warnings: IDE0270: Null check can be simplified * More SqlServer project warnings resolved * CS0105 namespace appeared already * Suppress warning until implementation: #pragma warning disable CS0162 // Unreachable code detected #pragma warning disable CS0618 // Type or member is obsolete CS0162 remove unreachable code SA1028 remove trailing whitespace SA1106 no empty statements CS1570 malformed XML CS1572 corrected xml parameter CS1573 param tag added IDE0007 var not explicit IDE0008 explicit not var IDE0057 simplify substring IDE0074 compound assignment CA1825 array.empty Down to 3479 warnings * - SA1116, SA117 params on same line - IDE0057 substring simplified Specific warnings for Umbraco.Tests.Benchmarks * Fixed IDE0074 compound assignment and added specific warnings for Umbraco.Tests.Common * Specific warnings for Umbraco.Tests.Integration and Umbraco.Tests.Common Fixed: - SA1111, SA1116, SA117 params and line formatting (not all as there are many) - SA1122 string.Empty - IDE0057 simplify substring - IDE0044,IDE0044 make field readonly - IDE1006 naming rule violation (add _) - SA1111 closing parenthesis on line of last parameter - SA1649 filename match type name - SA1312,SA1306 lowercase variable and field names * Fixed various warnings where they are more straight-forward, including: - SA1649 file name match type name - SA111 parenthesis on line of last parameter - IDE0028 simplify collection initializer - SA1306 lower-case letter field - IDE044 readonly field - SA1122 string.Empty - SA1116 params same line - IDE1006 upper casing - IDE0041 simplify null check Updated the following projects to only list their remaining specific warning codes: - Umbraco.Tests.UnitTests Typo in `Umbraco.Web.Website` project * Reverted test change * Now 1556 warnings. Fixed various warnings where they are more straight-forward, including: - SA1111/SA1116/SA1119 parenthesis - SA1117 params - SA1312 lowercase variable - SA1121 built-in type - SA1500/SA1513/SA1503 formatting braces - SA1400 declare access modifier - SA1122 string.Empty - SA1310 no underscore - IDE0049 name simplified - IDE0057 simplify substring - IDE0074 compound assignment - IDE0032 use auto-property - IDE0037 simplify member name - IDE0008 explicit type not var - IDE0016/IDE0270/IDE0041 simplify null checks - IDE0048/SA1407 clarity in arithmetic - IDE1006 correct param names - IDE0042 deconstruct variable - IDE0044 readonly - IDE0018 inline variable declarations - IDE0074/IDE0054 compound assignment - IDE1006 naming - CS1573 param XML - CS0168 unused variable Comment formatting in project files for consistency. Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default). * Type not var, and more warning exceptions * Tweaked merge issue, readded comment about rollback * Readded comment re rollback. * Readded comments * Comment tweak * Comment tweak
2024-09-24 12:56:28 +01:00
Assert.AreEqual(
content.Properties["keywords"].GetValue().ToString(),
element.Elements("keywords").Single().Value);
Resolved more warnings, and marked more warning types as errors (#16991) * Fix warnings SA1111, SA1028, SA1500, IDE1270 in Umbraco.Web.Website, and updated rules. * Remove warnings: IDE0270: Null check can be simplified * More SqlServer project warnings resolved * CS0105 namespace appeared already * Suppress warning until implementation: #pragma warning disable CS0162 // Unreachable code detected #pragma warning disable CS0618 // Type or member is obsolete CS0162 remove unreachable code SA1028 remove trailing whitespace SA1106 no empty statements CS1570 malformed XML CS1572 corrected xml parameter CS1573 param tag added IDE0007 var not explicit IDE0008 explicit not var IDE0057 simplify substring IDE0074 compound assignment CA1825 array.empty Down to 3479 warnings * - SA1116, SA117 params on same line - IDE0057 substring simplified Specific warnings for Umbraco.Tests.Benchmarks * Fixed IDE0074 compound assignment and added specific warnings for Umbraco.Tests.Common * Specific warnings for Umbraco.Tests.Integration and Umbraco.Tests.Common Fixed: - SA1111, SA1116, SA117 params and line formatting (not all as there are many) - SA1122 string.Empty - IDE0057 simplify substring - IDE0044,IDE0044 make field readonly - IDE1006 naming rule violation (add _) - SA1111 closing parenthesis on line of last parameter - SA1649 filename match type name - SA1312,SA1306 lowercase variable and field names * Fixed various warnings where they are more straight-forward, including: - SA1649 file name match type name - SA111 parenthesis on line of last parameter - IDE0028 simplify collection initializer - SA1306 lower-case letter field - IDE044 readonly field - SA1122 string.Empty - SA1116 params same line - IDE1006 upper casing - IDE0041 simplify null check Updated the following projects to only list their remaining specific warning codes: - Umbraco.Tests.UnitTests Typo in `Umbraco.Web.Website` project * Reverted test change * Now 1556 warnings. Fixed various warnings where they are more straight-forward, including: - SA1111/SA1116/SA1119 parenthesis - SA1117 params - SA1312 lowercase variable - SA1121 built-in type - SA1500/SA1513/SA1503 formatting braces - SA1400 declare access modifier - SA1122 string.Empty - SA1310 no underscore - IDE0049 name simplified - IDE0057 simplify substring - IDE0074 compound assignment - IDE0032 use auto-property - IDE0037 simplify member name - IDE0008 explicit type not var - IDE0016/IDE0270/IDE0041 simplify null checks - IDE0048/SA1407 clarity in arithmetic - IDE1006 correct param names - IDE0042 deconstruct variable - IDE0044 readonly - IDE0018 inline variable declarations - IDE0074/IDE0054 compound assignment - IDE1006 naming - CS1573 param XML - CS0168 unused variable Comment formatting in project files for consistency. Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default). * Type not var, and more warning exceptions * Tweaked merge issue, readded comment about rollback * Readded comment re rollback. * Readded comments * Comment tweak * Comment tweak
2024-09-24 12:56:28 +01:00
Assert.AreEqual(
content.Properties["description"].GetValue().ToString(),
element.Elements("description").Single().Value);
}
[Test]
public void Can_Generate_Xml_Representation_Of_Media()
{
// Arrange
var mediaType = MediaTypeBuilder.CreateImageMediaType("image2");
MediaTypeService.Save(mediaType);
// reference, so static ctor runs, so event handlers register
// and then, this will reset the width, height... because the file does not exist, of course ;-(
var loggerFactory = NullLoggerFactory.Instance;
var scheme = Mock.Of<IMediaPathScheme>();
var contentSettings = new ContentSettings();
var mediaFileManager = new MediaFileManager(
Mock.Of<IFileSystem>(),
scheme,
loggerFactory.CreateLogger<MediaFileManager>(),
ShortStringHelper,
Services);
var ignored = new FileUploadPropertyEditor(
DataValueEditorFactory,
IOHelper);
var media = MediaBuilder.CreateMediaImage(mediaType, -1);
media.WriterId = -1; // else it's zero and that's not a user and it breaks the tests
MediaService.Save(media);
// so we have to force-reset these values because the property editor has cleared them
media.SetValue(Constants.Conventions.Media.Width, "200");
media.SetValue(Constants.Conventions.Media.Height, "200");
media.SetValue(Constants.Conventions.Media.Bytes, "100");
media.SetValue(Constants.Conventions.Media.Extension, "png");
var nodeName = media.ContentType.Alias.ToSafeAlias(ShortStringHelper);
var urlName = media.GetUrlSegment(ShortStringHelper, new[] { new DefaultUrlSegmentProvider(ShortStringHelper) });
// Act
var element = media.ToXml(Serializer);
// Assert
Assert.That(element, Is.Not.Null);
Assert.That(element.Name.LocalName, Is.EqualTo(nodeName));
Assert.AreEqual(media.Id.ToString(), (string)element.Attribute("id"));
Assert.AreEqual(media.ParentId.ToString(), (string)element.Attribute("parentID"));
Assert.AreEqual(media.Level.ToString(), (string)element.Attribute("level"));
Assert.AreEqual(media.SortOrder.ToString(), (string)element.Attribute("sortOrder"));
Assert.AreEqual(media.CreateDate.ToString("s"), (string)element.Attribute("createDate"));
Assert.AreEqual(media.UpdateDate.ToString("s"), (string)element.Attribute("updateDate"));
Assert.AreEqual(media.Name, (string)element.Attribute("nodeName"));
Assert.AreEqual(urlName, (string)element.Attribute("urlName"));
Assert.AreEqual(media.Path, (string)element.Attribute("path"));
Resolved more warnings, and marked more warning types as errors (#16991) * Fix warnings SA1111, SA1028, SA1500, IDE1270 in Umbraco.Web.Website, and updated rules. * Remove warnings: IDE0270: Null check can be simplified * More SqlServer project warnings resolved * CS0105 namespace appeared already * Suppress warning until implementation: #pragma warning disable CS0162 // Unreachable code detected #pragma warning disable CS0618 // Type or member is obsolete CS0162 remove unreachable code SA1028 remove trailing whitespace SA1106 no empty statements CS1570 malformed XML CS1572 corrected xml parameter CS1573 param tag added IDE0007 var not explicit IDE0008 explicit not var IDE0057 simplify substring IDE0074 compound assignment CA1825 array.empty Down to 3479 warnings * - SA1116, SA117 params on same line - IDE0057 substring simplified Specific warnings for Umbraco.Tests.Benchmarks * Fixed IDE0074 compound assignment and added specific warnings for Umbraco.Tests.Common * Specific warnings for Umbraco.Tests.Integration and Umbraco.Tests.Common Fixed: - SA1111, SA1116, SA117 params and line formatting (not all as there are many) - SA1122 string.Empty - IDE0057 simplify substring - IDE0044,IDE0044 make field readonly - IDE1006 naming rule violation (add _) - SA1111 closing parenthesis on line of last parameter - SA1649 filename match type name - SA1312,SA1306 lowercase variable and field names * Fixed various warnings where they are more straight-forward, including: - SA1649 file name match type name - SA111 parenthesis on line of last parameter - IDE0028 simplify collection initializer - SA1306 lower-case letter field - IDE044 readonly field - SA1122 string.Empty - SA1116 params same line - IDE1006 upper casing - IDE0041 simplify null check Updated the following projects to only list their remaining specific warning codes: - Umbraco.Tests.UnitTests Typo in `Umbraco.Web.Website` project * Reverted test change * Now 1556 warnings. Fixed various warnings where they are more straight-forward, including: - SA1111/SA1116/SA1119 parenthesis - SA1117 params - SA1312 lowercase variable - SA1121 built-in type - SA1500/SA1513/SA1503 formatting braces - SA1400 declare access modifier - SA1122 string.Empty - SA1310 no underscore - IDE0049 name simplified - IDE0057 simplify substring - IDE0074 compound assignment - IDE0032 use auto-property - IDE0037 simplify member name - IDE0008 explicit type not var - IDE0016/IDE0270/IDE0041 simplify null checks - IDE0048/SA1407 clarity in arithmetic - IDE1006 correct param names - IDE0042 deconstruct variable - IDE0044 readonly - IDE0018 inline variable declarations - IDE0074/IDE0054 compound assignment - IDE1006 naming - CS1573 param XML - CS0168 unused variable Comment formatting in project files for consistency. Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default). * Type not var, and more warning exceptions * Tweaked merge issue, readded comment about rollback * Readded comment re rollback. * Readded comments * Comment tweak * Comment tweak
2024-09-24 12:56:28 +01:00
Assert.AreEqual(string.Empty, (string)element.Attribute("isDoc"));
Assert.AreEqual(media.ContentType.Id.ToString(), (string)element.Attribute("nodeType"));
Assert.AreEqual(media.GetCreatorProfile(UserService).Name, (string)element.Attribute("writerName"));
Assert.AreEqual(media.CreatorId.ToString(), (string)element.Attribute("writerID"));
Assert.IsNull(element.Attribute("template"));
Assert.AreEqual(media.Properties[Constants.Conventions.Media.File].GetValue().ToString(),
element.Elements(Constants.Conventions.Media.File).Single().Value);
Assert.AreEqual(media.Properties[Constants.Conventions.Media.Width].GetValue().ToString(),
element.Elements(Constants.Conventions.Media.Width).Single().Value);
Assert.AreEqual(media.Properties[Constants.Conventions.Media.Height].GetValue().ToString(),
element.Elements(Constants.Conventions.Media.Height).Single().Value);
Assert.AreEqual(media.Properties[Constants.Conventions.Media.Bytes].GetValue().ToString(),
element.Elements(Constants.Conventions.Media.Bytes).Single().Value);
Assert.AreEqual(media.Properties[Constants.Conventions.Media.Extension].GetValue().ToString(),
element.Elements(Constants.Conventions.Media.Extension).Single().Value);
}
[Test]
public void Serialize_ForContentTypeWithHistoryCleanupPolicy_OutputsSerializedHistoryCleanupPolicy()
{
// Arrange
var template = TemplateBuilder.CreateTextPageTemplate();
FileService.SaveTemplate(template); // else, FK violation on contentType!
var contentType = ContentTypeBuilder.CreateTextPageContentType(defaultTemplateId: template.Id);
contentType.HistoryCleanup = new HistoryCleanup
Cherry-pick: support import/export for doc type history cleanup policy (#11708) * cherry-pick 13a51d32 (V8 History cleanup import/export) Support import/export for doc type history cleanup policy (#11660) * Support import/export for doc type history cleanup policy * Support unset/null history cleanup value * Resolve issue when api endpoints called without cleanup policy. noop isn't good enough as map fails for response. * null conditional vs null coalesce assignment * Don't overwrite existing policy if omitted in import XML * Update history cleanup warning and translations * Change history cleanup alert to infomational styling * Remove margin around history cleanup config Co-authored-by: Ronald Barendse <ronald@barend.se> # Conflicts: # src/Umbraco.Core/Models/IContentType.cs # src/Umbraco.Core/Packaging/PackageDataInstallation.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs # src/Umbraco.Infrastructure/Services/Implement/EntityXmlSerializer.cs # src/Umbraco.Tests/Packaging/PackageDataInstallationTests.cs # src/Umbraco.Tests/Services/Importing/ImportResources.Designer.cs # src/Umbraco.Tests/Umbraco.Tests.csproj # src/Umbraco.Web.UI/umbraco/config/lang/en.xml # src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml # src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs # tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/Importing/ImportResources.resx # tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/Importing/SingleDocType-WithCleanupPolicy.xml * Remove namespace aliases * Update IContentTypeWithHistoryCleanup documentation Co-authored-by: Ronald Barendse <ronald@barend.se>
2021-12-02 10:37:12 +00:00
{
PreventCleanup = true,
KeepAllVersionsNewerThanDays = 1,
KeepLatestVersionPerDayForDays = 2
};
ContentTypeService.Save(contentType);
// Act
var element = Serializer.Serialize(contentType);
// Assert
Assert.Multiple(() =>
Cherry-pick: support import/export for doc type history cleanup policy (#11708) * cherry-pick 13a51d32 (V8 History cleanup import/export) Support import/export for doc type history cleanup policy (#11660) * Support import/export for doc type history cleanup policy * Support unset/null history cleanup value * Resolve issue when api endpoints called without cleanup policy. noop isn't good enough as map fails for response. * null conditional vs null coalesce assignment * Don't overwrite existing policy if omitted in import XML * Update history cleanup warning and translations * Change history cleanup alert to infomational styling * Remove margin around history cleanup config Co-authored-by: Ronald Barendse <ronald@barend.se> # Conflicts: # src/Umbraco.Core/Models/IContentType.cs # src/Umbraco.Core/Packaging/PackageDataInstallation.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs # src/Umbraco.Infrastructure/Services/Implement/EntityXmlSerializer.cs # src/Umbraco.Tests/Packaging/PackageDataInstallationTests.cs # src/Umbraco.Tests/Services/Importing/ImportResources.Designer.cs # src/Umbraco.Tests/Umbraco.Tests.csproj # src/Umbraco.Web.UI/umbraco/config/lang/en.xml # src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml # src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs # tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/Importing/ImportResources.resx # tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/Importing/SingleDocType-WithCleanupPolicy.xml * Remove namespace aliases * Update IContentTypeWithHistoryCleanup documentation Co-authored-by: Ronald Barendse <ronald@barend.se>
2021-12-02 10:37:12 +00:00
{
Assert.That(element.Element("HistoryCleanupPolicy")!.Attribute("preventCleanup")!.Value,
Is.EqualTo("true"));
Assert.That(element.Element("HistoryCleanupPolicy")!.Attribute("keepAllVersionsNewerThanDays")!.Value,
Is.EqualTo("1"));
Assert.That(element.Element("HistoryCleanupPolicy")!.Attribute("keepLatestVersionPerDayForDays")!.Value,
Is.EqualTo("2"));
});
}
[Test]
public void Serialize_ForContentTypeWithNullHistoryCleanupPolicy_DoesNotOutputSerializedDefaultPolicy()
{
// Arrange
var template = TemplateBuilder.CreateTextPageTemplate();
FileService.SaveTemplate(template); // else, FK violation on contentType!
var contentType = ContentTypeBuilder.CreateTextPageContentType(defaultTemplateId: template.Id);
Cherry-pick: support import/export for doc type history cleanup policy (#11708) * cherry-pick 13a51d32 (V8 History cleanup import/export) Support import/export for doc type history cleanup policy (#11660) * Support import/export for doc type history cleanup policy * Support unset/null history cleanup value * Resolve issue when api endpoints called without cleanup policy. noop isn't good enough as map fails for response. * null conditional vs null coalesce assignment * Don't overwrite existing policy if omitted in import XML * Update history cleanup warning and translations * Change history cleanup alert to infomational styling * Remove margin around history cleanup config Co-authored-by: Ronald Barendse <ronald@barend.se> # Conflicts: # src/Umbraco.Core/Models/IContentType.cs # src/Umbraco.Core/Packaging/PackageDataInstallation.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs # src/Umbraco.Infrastructure/Services/Implement/EntityXmlSerializer.cs # src/Umbraco.Tests/Packaging/PackageDataInstallationTests.cs # src/Umbraco.Tests/Services/Importing/ImportResources.Designer.cs # src/Umbraco.Tests/Umbraco.Tests.csproj # src/Umbraco.Web.UI/umbraco/config/lang/en.xml # src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml # src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs # tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/Importing/ImportResources.resx # tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/Importing/SingleDocType-WithCleanupPolicy.xml * Remove namespace aliases * Update IContentTypeWithHistoryCleanup documentation Co-authored-by: Ronald Barendse <ronald@barend.se>
2021-12-02 10:37:12 +00:00
contentType.HistoryCleanup = null;
Cherry-pick: support import/export for doc type history cleanup policy (#11708) * cherry-pick 13a51d32 (V8 History cleanup import/export) Support import/export for doc type history cleanup policy (#11660) * Support import/export for doc type history cleanup policy * Support unset/null history cleanup value * Resolve issue when api endpoints called without cleanup policy. noop isn't good enough as map fails for response. * null conditional vs null coalesce assignment * Don't overwrite existing policy if omitted in import XML * Update history cleanup warning and translations * Change history cleanup alert to infomational styling * Remove margin around history cleanup config Co-authored-by: Ronald Barendse <ronald@barend.se> # Conflicts: # src/Umbraco.Core/Models/IContentType.cs # src/Umbraco.Core/Packaging/PackageDataInstallation.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs # src/Umbraco.Infrastructure/Services/Implement/EntityXmlSerializer.cs # src/Umbraco.Tests/Packaging/PackageDataInstallationTests.cs # src/Umbraco.Tests/Services/Importing/ImportResources.Designer.cs # src/Umbraco.Tests/Umbraco.Tests.csproj # src/Umbraco.Web.UI/umbraco/config/lang/en.xml # src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml # src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs # tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/Importing/ImportResources.resx # tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/Importing/SingleDocType-WithCleanupPolicy.xml * Remove namespace aliases * Update IContentTypeWithHistoryCleanup documentation Co-authored-by: Ronald Barendse <ronald@barend.se>
2021-12-02 10:37:12 +00:00
ContentTypeService.Save(contentType);
Cherry-pick: support import/export for doc type history cleanup policy (#11708) * cherry-pick 13a51d32 (V8 History cleanup import/export) Support import/export for doc type history cleanup policy (#11660) * Support import/export for doc type history cleanup policy * Support unset/null history cleanup value * Resolve issue when api endpoints called without cleanup policy. noop isn't good enough as map fails for response. * null conditional vs null coalesce assignment * Don't overwrite existing policy if omitted in import XML * Update history cleanup warning and translations * Change history cleanup alert to infomational styling * Remove margin around history cleanup config Co-authored-by: Ronald Barendse <ronald@barend.se> # Conflicts: # src/Umbraco.Core/Models/IContentType.cs # src/Umbraco.Core/Packaging/PackageDataInstallation.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs # src/Umbraco.Infrastructure/Services/Implement/EntityXmlSerializer.cs # src/Umbraco.Tests/Packaging/PackageDataInstallationTests.cs # src/Umbraco.Tests/Services/Importing/ImportResources.Designer.cs # src/Umbraco.Tests/Umbraco.Tests.csproj # src/Umbraco.Web.UI/umbraco/config/lang/en.xml # src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml # src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs # tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/Importing/ImportResources.resx # tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/Importing/SingleDocType-WithCleanupPolicy.xml * Remove namespace aliases * Update IContentTypeWithHistoryCleanup documentation Co-authored-by: Ronald Barendse <ronald@barend.se>
2021-12-02 10:37:12 +00:00
var element = Serializer.Serialize(contentType);
Cherry-pick: support import/export for doc type history cleanup policy (#11708) * cherry-pick 13a51d32 (V8 History cleanup import/export) Support import/export for doc type history cleanup policy (#11660) * Support import/export for doc type history cleanup policy * Support unset/null history cleanup value * Resolve issue when api endpoints called without cleanup policy. noop isn't good enough as map fails for response. * null conditional vs null coalesce assignment * Don't overwrite existing policy if omitted in import XML * Update history cleanup warning and translations * Change history cleanup alert to infomational styling * Remove margin around history cleanup config Co-authored-by: Ronald Barendse <ronald@barend.se> # Conflicts: # src/Umbraco.Core/Models/IContentType.cs # src/Umbraco.Core/Packaging/PackageDataInstallation.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs # src/Umbraco.Infrastructure/Services/Implement/EntityXmlSerializer.cs # src/Umbraco.Tests/Packaging/PackageDataInstallationTests.cs # src/Umbraco.Tests/Services/Importing/ImportResources.Designer.cs # src/Umbraco.Tests/Umbraco.Tests.csproj # src/Umbraco.Web.UI/umbraco/config/lang/en.xml # src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml # src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs # tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/Importing/ImportResources.resx # tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/Importing/SingleDocType-WithCleanupPolicy.xml * Remove namespace aliases * Update IContentTypeWithHistoryCleanup documentation Co-authored-by: Ronald Barendse <ronald@barend.se>
2021-12-02 10:37:12 +00:00
// Assert
Assert.Multiple(() =>
{
Assert.That(element.Element("HistoryCleanupPolicy"), Is.Null);
});
}
private async Task CreateDictionaryData()
{
var languageService = GetRequiredService<ILanguageService>();
var dictionaryItemService = GetRequiredService<IDictionaryItemService>();
var languageNbNo = new LanguageBuilder()
.WithCultureInfo("nb-NO")
.WithCultureName("Norwegian")
.Build();
await languageService.CreateAsync(languageNbNo, Constants.Security.SuperUserKey);
Cherry-pick: support import/export for doc type history cleanup policy (#11708) * cherry-pick 13a51d32 (V8 History cleanup import/export) Support import/export for doc type history cleanup policy (#11660) * Support import/export for doc type history cleanup policy * Support unset/null history cleanup value * Resolve issue when api endpoints called without cleanup policy. noop isn't good enough as map fails for response. * null conditional vs null coalesce assignment * Don't overwrite existing policy if omitted in import XML * Update history cleanup warning and translations * Change history cleanup alert to infomational styling * Remove margin around history cleanup config Co-authored-by: Ronald Barendse <ronald@barend.se> # Conflicts: # src/Umbraco.Core/Models/IContentType.cs # src/Umbraco.Core/Packaging/PackageDataInstallation.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs # src/Umbraco.Infrastructure/Services/Implement/EntityXmlSerializer.cs # src/Umbraco.Tests/Packaging/PackageDataInstallationTests.cs # src/Umbraco.Tests/Services/Importing/ImportResources.Designer.cs # src/Umbraco.Tests/Umbraco.Tests.csproj # src/Umbraco.Web.UI/umbraco/config/lang/en.xml # src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml # src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs # tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/Importing/ImportResources.resx # tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/Importing/SingleDocType-WithCleanupPolicy.xml * Remove namespace aliases * Update IContentTypeWithHistoryCleanup documentation Co-authored-by: Ronald Barendse <ronald@barend.se>
2021-12-02 10:37:12 +00:00
var languageEnGb = new LanguageBuilder()
.WithCultureInfo("en-GB")
.Build();
await languageService.CreateAsync(languageEnGb, Constants.Security.SuperUserKey);
var parentKey = Guid.Parse("28f2e02a-8c66-4fcd-85e3-8524d551c0d3");
var parentItem = new DictionaryItem("Parent") { Key = parentKey };
var parentTranslations = new List<IDictionaryTranslation>
{
new DictionaryTranslation(languageNbNo, "ForelderVerdi"),
new DictionaryTranslation(languageEnGb, "ParentValue")
};
parentItem.Translations = parentTranslations;
var result = await dictionaryItemService.CreateAsync(parentItem, Constants.Security.SuperUserKey);
Assert.IsTrue(result.Success);
Assert.AreEqual(parentKey, result.Result.Key);
var childKey = Guid.Parse("e7dba0a9-d517-4ba4-8e18-2764d392c611");
var childItem =
new DictionaryItem(parentItem.Key, "Child") { Key = childKey };
var childTranslations = new List<IDictionaryTranslation>
{
new DictionaryTranslation(languageNbNo, "BarnVerdi"),
new DictionaryTranslation(languageEnGb, "ChildValue")
};
childItem.Translations = childTranslations;
result = await dictionaryItemService.CreateAsync(childItem, Constants.Security.SuperUserKey);
Assert.IsTrue(result.Success);
Assert.AreEqual(childKey, result.Result.Key);
}
}