From 874e585bfba8410e7c56cfcbfdb01417763b5b00 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Sat, 10 Oct 2020 18:25:18 +0200 Subject: [PATCH] Migrated EntityXmlSerializerTests. Also aligned namespaces and update LocalizationServiceTests to use test model builders. --- .../Builders/Extensions/BuilderExtensions.cs | 4 +- .../Builders/LanguageBuilder.cs | 10 +- .../Services/CachedDataTypeServiceTests.cs | 2 +- .../ContentServicePublishBranchTests.cs | 2 +- .../Services/DataTypeServiceTests.cs | 3 +- .../Services/EntityServiceTests.cs | 2 +- .../Services/EntityXmlSerializerTests.cs | 64 +++++---- .../Services/FileServiceTests.cs | 3 +- .../Services/Importing/Dictionary-Package.xml | 36 +++++ .../Importing/ImportResources.Designer.cs | 89 +++++++++++++ .../Services/Importing/ImportResources.resx | 124 ++++++++++++++++++ .../Services/KeyValueServiceTests.cs | 4 +- .../Services/LocalizationServiceTests.cs | 108 +++++++++------ .../Umbraco.Tests.Integration.csproj | 24 ++++ .../Builders/LanguageBuilderTests.cs | 1 + .../Services/Importing/Dictionary-Package.xml | 4 +- src/Umbraco.Tests/Umbraco.Tests.csproj | 11 +- 17 files changed, 401 insertions(+), 90 deletions(-) rename src/{Umbraco.Tests => Umbraco.Tests.Integration}/Services/EntityXmlSerializerTests.cs (60%) create mode 100644 src/Umbraco.Tests.Integration/Services/Importing/Dictionary-Package.xml create mode 100644 src/Umbraco.Tests.Integration/Services/Importing/ImportResources.Designer.cs create mode 100644 src/Umbraco.Tests.Integration/Services/Importing/ImportResources.resx diff --git a/src/Umbraco.Tests.Common/Builders/Extensions/BuilderExtensions.cs b/src/Umbraco.Tests.Common/Builders/Extensions/BuilderExtensions.cs index 1171727169..992b7661d4 100644 --- a/src/Umbraco.Tests.Common/Builders/Extensions/BuilderExtensions.cs +++ b/src/Umbraco.Tests.Common/Builders/Extensions/BuilderExtensions.cs @@ -202,10 +202,10 @@ namespace Umbraco.Tests.Common.Builders.Extensions return builder; } - public static T WithCultureInfo(this T builder, string name) + public static T WithCultureInfo(this T builder, string cultureCode) where T : IWithCultureInfoBuilder { - builder.CultureInfo = CultureInfo.GetCultureInfo(name); + builder.CultureInfo = CultureInfo.GetCultureInfo(cultureCode); return builder; } diff --git a/src/Umbraco.Tests.Common/Builders/LanguageBuilder.cs b/src/Umbraco.Tests.Common/Builders/LanguageBuilder.cs index cb76a00f92..4cd924fa3a 100644 --- a/src/Umbraco.Tests.Common/Builders/LanguageBuilder.cs +++ b/src/Umbraco.Tests.Common/Builders/LanguageBuilder.cs @@ -24,6 +24,7 @@ namespace Umbraco.Tests.Common.Builders { private DateTime? _createDate; private CultureInfo _cultureInfo; + private string _cultureName; private DateTime? _deleteDate; private int? _fallbackLanguageId; private int? _id; @@ -36,6 +37,12 @@ namespace Umbraco.Tests.Common.Builders { } + public LanguageBuilder WithCultureName(string cultureName) + { + _cultureName = cultureName; + return this; + } + public LanguageBuilder WithIsDefault(bool isDefault) { _isDefault = isDefault; @@ -57,6 +64,7 @@ namespace Umbraco.Tests.Common.Builders public override ILanguage Build() { var cultureInfo = _cultureInfo ?? CultureInfo.GetCultureInfo("en-US"); + var cultureName = _cultureName ?? cultureInfo.EnglishName; var globalSettings = new GlobalSettings { DefaultUILanguage = cultureInfo.Name }; var key = _key ?? Guid.NewGuid(); var createDate = _createDate ?? DateTime.Now; @@ -69,7 +77,7 @@ namespace Umbraco.Tests.Common.Builders return new Language(globalSettings, cultureInfo.Name) { Id = _id ?? 0, - CultureName = cultureInfo.EnglishName, + CultureName = cultureName, IsoCode = cultureInfo.Name, Key = key, CreateDate = createDate, diff --git a/src/Umbraco.Tests.Integration/Services/CachedDataTypeServiceTests.cs b/src/Umbraco.Tests.Integration/Services/CachedDataTypeServiceTests.cs index c0853eac6e..a5b89dc2cf 100644 --- a/src/Umbraco.Tests.Integration/Services/CachedDataTypeServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Services/CachedDataTypeServiceTests.cs @@ -6,7 +6,7 @@ using Umbraco.Core.Services; using Umbraco.Tests.Integration.Testing; using Umbraco.Tests.Testing; -namespace Umbraco.Tests.Services +namespace Umbraco.Tests.Integration.Services { /// /// Tests covering the DataTypeService with cache enabled diff --git a/src/Umbraco.Tests.Integration/Services/ContentServicePublishBranchTests.cs b/src/Umbraco.Tests.Integration/Services/ContentServicePublishBranchTests.cs index 9e45e40c42..54103af6f1 100644 --- a/src/Umbraco.Tests.Integration/Services/ContentServicePublishBranchTests.cs +++ b/src/Umbraco.Tests.Integration/Services/ContentServicePublishBranchTests.cs @@ -11,7 +11,7 @@ using Umbraco.Tests.Testing; // ReSharper disable CommentTypo // ReSharper disable StringLiteralTypo -namespace Umbraco.Tests.Services +namespace Umbraco.Tests.Integration.Services { [TestFixture] [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, PublishedRepositoryEvents = true, WithApplication = true)] diff --git a/src/Umbraco.Tests.Integration/Services/DataTypeServiceTests.cs b/src/Umbraco.Tests.Integration/Services/DataTypeServiceTests.cs index 16715b5656..160769439d 100644 --- a/src/Umbraco.Tests.Integration/Services/DataTypeServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Services/DataTypeServiceTests.cs @@ -7,10 +7,9 @@ using Umbraco.Core.PropertyEditors; using Umbraco.Core.Services; using Umbraco.Tests.Common.Builders; using Umbraco.Tests.Integration.Testing; -using Umbraco.Tests.TestHelpers.Entities; using Umbraco.Tests.Testing; -namespace Umbraco.Tests.Services +namespace Umbraco.Tests.Integration.Services { /// /// Tests covering the DataTypeService diff --git a/src/Umbraco.Tests.Integration/Services/EntityServiceTests.cs b/src/Umbraco.Tests.Integration/Services/EntityServiceTests.cs index 1058cd6558..64e7cea8dc 100644 --- a/src/Umbraco.Tests.Integration/Services/EntityServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Services/EntityServiceTests.cs @@ -13,7 +13,7 @@ using Umbraco.Tests.Common.Builders; using Umbraco.Tests.Integration.Testing; using Umbraco.Tests.Testing; -namespace Umbraco.Tests.Services +namespace Umbraco.Tests.Integration.Services { /// /// Tests covering the EntityService diff --git a/src/Umbraco.Tests/Services/EntityXmlSerializerTests.cs b/src/Umbraco.Tests.Integration/Services/EntityXmlSerializerTests.cs similarity index 60% rename from src/Umbraco.Tests/Services/EntityXmlSerializerTests.cs rename to src/Umbraco.Tests.Integration/Services/EntityXmlSerializerTests.cs index 1e8e6bd17d..5bc16a4cdb 100644 --- a/src/Umbraco.Tests/Services/EntityXmlSerializerTests.cs +++ b/src/Umbraco.Tests.Integration/Services/EntityXmlSerializerTests.cs @@ -3,35 +3,32 @@ using System.Diagnostics; using System.Linq; using System.Xml.Linq; using NUnit.Framework; -using Umbraco.Core; -using Umbraco.Core.Configuration.Models; using Umbraco.Core.Models; using Umbraco.Core.Services; using Umbraco.Tests.Common.Builders; -using Umbraco.Tests.Services.Importing; +using Umbraco.Tests.Common.Builders.Extensions; +using Umbraco.Tests.Integration.Services.Importing; +using Umbraco.Tests.Integration.Testing; using Umbraco.Tests.Testing; -namespace Umbraco.Tests.Services +namespace Umbraco.Tests.Integration.Services { [TestFixture] [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)] - public class EntityXmlSerializerTests : TestWithSomeContentBase + public class EntityXmlSerializerTests : UmbracoIntegrationTest { - private IEntityXmlSerializer Serializer => Factory.GetInstance(); - private GlobalSettings _globalSettings; - - public override void SetUp() - { - base.SetUp(); - _globalSettings = new GlobalSettings(); - } + private IEntityXmlSerializer Serializer => GetRequiredService(); [Test] public void Can_Export_Macro() { // Arrange - var macro = new Macro(ShortStringHelper, "test1", "Test", "~/views/macropartials/test.cshtml"); - ServiceContext.MacroService.Save(macro); + var macroService = GetRequiredService(); + var macro = new MacroBuilder() + .WithAlias("test1") + .WithName("Test") + .Build(); + macroService.Save(macro); // Act var element = Serializer.Serialize(macro); @@ -48,7 +45,8 @@ namespace Umbraco.Tests.Services { // Arrange CreateDictionaryData(); - var dictionaryItem = ServiceContext.LocalizationService.GetDictionaryItemByKey("Parent"); + var localizationService = GetRequiredService(); + var dictionaryItem = localizationService.GetDictionaryItemByKey("Parent"); var newPackageXml = XElement.Parse(ImportResources.Dictionary_Package); var dictionaryItemsElement = newPackageXml.Elements("DictionaryItems").First(); @@ -64,11 +62,18 @@ namespace Umbraco.Tests.Services public void Can_Export_Languages() { // Arrange - var languageNbNo = new Language(_globalSettings, "nb-NO") { CultureName = "Norwegian" }; - ServiceContext.LocalizationService.Save(languageNbNo); + var localizationService = GetRequiredService(); - var languageEnGb = new Language(_globalSettings, "en-GB") { CultureName = "English (United Kingdom)" }; - ServiceContext.LocalizationService.Save(languageEnGb); + var languageNbNo = new LanguageBuilder() + .WithCultureInfo("nb-NO") + .WithCultureName("Norwegian") + .Build(); + localizationService.Save(languageNbNo); + + var languageEnGb = new LanguageBuilder() + .WithCultureInfo("en-GB") + .Build(); + localizationService.Save(languageEnGb); var newPackageXml = XElement.Parse(ImportResources.Dictionary_Package); var languageItemsElement = newPackageXml.Elements("Languages").First(); @@ -82,11 +87,18 @@ namespace Umbraco.Tests.Services private void CreateDictionaryData() { - var languageNbNo = new Language(_globalSettings, "nb-NO") { CultureName = "nb-NO" }; - ServiceContext.LocalizationService.Save(languageNbNo); + var localizationService = GetRequiredService(); - var languageEnGb = new Language(_globalSettings, "en-GB") { CultureName = "en-GB" }; - ServiceContext.LocalizationService.Save(languageEnGb); + var languageNbNo = new LanguageBuilder() + .WithCultureInfo("nb-NO") + .WithCultureName("Norwegian") + .Build(); + localizationService.Save(languageNbNo); + + var languageEnGb = new LanguageBuilder() + .WithCultureInfo("en-GB") + .Build(); + localizationService.Save(languageEnGb); var parentItem = new DictionaryItem("Parent"); var parentTranslations = new List @@ -95,7 +107,7 @@ namespace Umbraco.Tests.Services new DictionaryTranslation(languageEnGb, "ParentValue") }; parentItem.Translations = parentTranslations; - ServiceContext.LocalizationService.Save(parentItem); + localizationService.Save(parentItem); var childItem = new DictionaryItem(parentItem.Key, "Child"); var childTranslations = new List @@ -104,7 +116,7 @@ namespace Umbraco.Tests.Services new DictionaryTranslation(languageEnGb, "ChildValue") }; childItem.Translations = childTranslations; - ServiceContext.LocalizationService.Save(childItem); + localizationService.Save(childItem); } } } diff --git a/src/Umbraco.Tests.Integration/Services/FileServiceTests.cs b/src/Umbraco.Tests.Integration/Services/FileServiceTests.cs index 52a0b0e654..8a4a0535b6 100644 --- a/src/Umbraco.Tests.Integration/Services/FileServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Services/FileServiceTests.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using NUnit.Framework; @@ -7,7 +6,7 @@ using Umbraco.Core.Services; using Umbraco.Tests.Integration.Testing; using Umbraco.Tests.Testing; -namespace Umbraco.Tests.Services +namespace Umbraco.Tests.Integration.Services { [TestFixture] [Apartment(ApartmentState.STA)] diff --git a/src/Umbraco.Tests.Integration/Services/Importing/Dictionary-Package.xml b/src/Umbraco.Tests.Integration/Services/Importing/Dictionary-Package.xml new file mode 100644 index 0000000000..8324ea4ef4 --- /dev/null +++ b/src/Umbraco.Tests.Integration/Services/Importing/Dictionary-Package.xml @@ -0,0 +1,36 @@ + + + + + + Dictionary-Package + 1.0 + MIT license + http://not.available + + 3 + 0 + 0 + + + + Test + http://not.available + + + + + + + + + + + + + + + + + + diff --git a/src/Umbraco.Tests.Integration/Services/Importing/ImportResources.Designer.cs b/src/Umbraco.Tests.Integration/Services/Importing/ImportResources.Designer.cs new file mode 100644 index 0000000000..4925956fb8 --- /dev/null +++ b/src/Umbraco.Tests.Integration/Services/Importing/ImportResources.Designer.cs @@ -0,0 +1,89 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Umbraco.Tests.Integration.Services.Importing { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class ImportResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal ImportResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Umbraco.Tests.Integration.Services.Importing.ImportResources", typeof(ImportResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8" ?> + ///<umbPackage> + /// <files /> + /// <info> + /// <package> + /// <name>Dictionary-Package</name> + /// <version>1.0</version> + /// <license url="http://www.opensource.org/licenses/mit-license.php">MIT license</license> + /// <url>http://not.available</url> + /// <requirements> + /// <major>3</major> + /// <minor>0</minor> + /// <patch>0</patch> + /// </requirements> + /// </package> + /// <author> + /// <name>Test</name> + /// <website>http://not.available</w [rest of string was truncated]";. + /// + internal static string Dictionary_Package { + get { + return ResourceManager.GetString("Dictionary_Package", resourceCulture); + } + } + } +} diff --git a/src/Umbraco.Tests.Integration/Services/Importing/ImportResources.resx b/src/Umbraco.Tests.Integration/Services/Importing/ImportResources.resx new file mode 100644 index 0000000000..5823fa1245 --- /dev/null +++ b/src/Umbraco.Tests.Integration/Services/Importing/ImportResources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + dictionary-package.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + \ No newline at end of file diff --git a/src/Umbraco.Tests.Integration/Services/KeyValueServiceTests.cs b/src/Umbraco.Tests.Integration/Services/KeyValueServiceTests.cs index 17c601e9ec..8694e88395 100644 --- a/src/Umbraco.Tests.Integration/Services/KeyValueServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Services/KeyValueServiceTests.cs @@ -4,12 +4,10 @@ using Umbraco.Core.Services; using Umbraco.Tests.Integration.Testing; using Umbraco.Tests.Testing; -namespace Umbraco.Tests.Services +namespace Umbraco.Tests.Integration.Services { /// /// Tests covering methods in the KeyValueService class. - /// This is more of an integration test as it involves multiple layers - /// as well as configuration. /// [TestFixture] [Apartment(ApartmentState.STA)] diff --git a/src/Umbraco.Tests.Integration/Services/LocalizationServiceTests.cs b/src/Umbraco.Tests.Integration/Services/LocalizationServiceTests.cs index 83d3476324..a2847b64fe 100644 --- a/src/Umbraco.Tests.Integration/Services/LocalizationServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Services/LocalizationServiceTests.cs @@ -4,10 +4,11 @@ using System.Diagnostics; using System.Linq; using System.Threading; using NUnit.Framework; -using Umbraco.Core.Configuration.Models; using Umbraco.Core.Models; using Umbraco.Core.Persistence; using Umbraco.Core.Services; +using Umbraco.Tests.Common.Builders; +using Umbraco.Tests.Common.Builders.Extensions; using Umbraco.Tests.Integration.Testing; using Umbraco.Tests.Testing; @@ -30,13 +31,11 @@ namespace Umbraco.Tests.Integration.Services private int _danishLangId; private int _englishLangId; - private GlobalSettings _globalSettings; private ILocalizationService LocalizationService => GetRequiredService(); [SetUp] public void SetUp() { - _globalSettings = new GlobalSettings(); CreateTestData(); } @@ -191,12 +190,14 @@ namespace Umbraco.Tests.Integration.Services [Test] public void Can_Delete_Language() { - var norwegian = new Language(_globalSettings, "nb-NO") { CultureName = "Norwegian" }; - LocalizationService.Save(norwegian, 0); - Assert.That(norwegian.HasIdentity, Is.True); - var languageId = norwegian.Id; + var languageNbNo = new LanguageBuilder() + .WithCultureInfo("nb-NO") + .Build(); + LocalizationService.Save(languageNbNo, 0); + Assert.That(languageNbNo.HasIdentity, Is.True); + var languageId = languageNbNo.Id; - LocalizationService.Delete(norwegian); + LocalizationService.Delete(languageNbNo); var language = LocalizationService.GetLanguageById(languageId); Assert.Null(language); @@ -205,12 +206,15 @@ namespace Umbraco.Tests.Integration.Services [Test] public void Can_Delete_Language_Used_As_Fallback() { - var danish = LocalizationService.GetLanguageByIsoCode("da-DK"); - var norwegian = new Language(_globalSettings, "nb-NO") { CultureName = "Norwegian", FallbackLanguageId = danish.Id }; - LocalizationService.Save(norwegian, 0); - var languageId = danish.Id; + var languageDaDk = LocalizationService.GetLanguageByIsoCode("da-DK"); + var languageNbNo = new LanguageBuilder() + .WithCultureInfo("nb-NO") + .WithFallbackLanguageId(languageDaDk.Id) + .Build(); + LocalizationService.Save(languageNbNo, 0); + var languageId = languageDaDk.Id; - LocalizationService.Delete(danish); + LocalizationService.Delete(languageDaDk); var language = LocalizationService.GetLanguageById(languageId); Assert.Null(language); @@ -350,10 +354,12 @@ namespace Umbraco.Tests.Integration.Services { // Arrange var isoCode = "en-AU"; - var language = new Core.Models.Language(_globalSettings, isoCode); + var languageEnAu = new LanguageBuilder() + .WithCultureInfo(isoCode) + .Build(); // Act - LocalizationService.Save(language); + LocalizationService.Save(languageEnAu); var result = LocalizationService.GetLanguageByIsoCode(isoCode); // Assert @@ -363,12 +369,14 @@ namespace Umbraco.Tests.Integration.Services [Test] public void Save_Language_And_GetLanguageById() { - var isoCode = "en-AU"; - var language = new Core.Models.Language(_globalSettings, isoCode); + // Arrange + var languageEnAu = new LanguageBuilder() + .WithCultureInfo("en-AU") + .Build(); // Act - LocalizationService.Save(language); - var result = LocalizationService.GetLanguageById(language.Id); + LocalizationService.Save(languageEnAu); + var result = LocalizationService.GetLanguageById(languageEnAu.Id); // Assert Assert.NotNull(result); @@ -377,17 +385,24 @@ namespace Umbraco.Tests.Integration.Services [Test] public void Set_Default_Language() { - var language = new Language(_globalSettings, "en-AU") {IsDefault = true}; - LocalizationService.Save(language); - var result = LocalizationService.GetLanguageById(language.Id); + var languageEnAu = new LanguageBuilder() + .WithCultureInfo("en-AU") + .WithIsDefault(true) + .Build(); + LocalizationService.Save(languageEnAu); + var result = LocalizationService.GetLanguageById(languageEnAu.Id); Assert.IsTrue(result.IsDefault); - var language2 = new Language(_globalSettings, "en-NZ") {IsDefault = true}; - LocalizationService.Save(language2); - var result2 = LocalizationService.GetLanguageById(language2.Id); + var languageEnNz = new LanguageBuilder() + .WithCultureInfo("en-NZ") + .WithIsDefault(true) + .Build(); + LocalizationService.Save(languageEnNz); + var result2 = LocalizationService.GetLanguageById(languageEnNz.Id); + //re-get - result = LocalizationService.GetLanguageById(language.Id); + result = LocalizationService.GetLanguageById(languageEnAu.Id); Assert.IsTrue(result2.IsDefault); Assert.IsFalse(result.IsDefault); @@ -397,11 +412,13 @@ namespace Umbraco.Tests.Integration.Services public void Deleted_Language_Should_Not_Exist() { var isoCode = "en-AU"; - var language = new Core.Models.Language(_globalSettings, isoCode); - LocalizationService.Save(language); + var languageEnAu = new LanguageBuilder() + .WithCultureInfo(isoCode) + .Build(); + LocalizationService.Save(languageEnAu); // Act - LocalizationService.Delete(language); + LocalizationService.Delete(languageEnAu); var result = LocalizationService.GetLanguageByIsoCode(isoCode); // Assert @@ -410,20 +427,25 @@ namespace Umbraco.Tests.Integration.Services public void CreateTestData() { - var danish = new Language(_globalSettings, "da-DK") { CultureName = "Danish" }; - var english = new Language(_globalSettings, "en-GB") { CultureName = "English" }; - LocalizationService.Save(danish, 0); - LocalizationService.Save(english, 0); - _danishLangId = danish.Id; - _englishLangId = english.Id; + var languageDaDk = new LanguageBuilder() + .WithCultureInfo("da-DK") + .Build(); + var languageEnGb = new LanguageBuilder() + .WithCultureInfo("en-GB") + .Build(); + + LocalizationService.Save(languageDaDk, 0); + LocalizationService.Save(languageEnGb, 0); + _danishLangId = languageDaDk.Id; + _englishLangId = languageEnGb.Id; var parentItem = new DictionaryItem("Parent") { Translations = new List - { - new DictionaryTranslation(english, "ParentValue"), - new DictionaryTranslation(danish, "ForældreVærdi") - } + { + new DictionaryTranslation(languageEnGb, "ParentValue"), + new DictionaryTranslation(languageDaDk, "ForældreVærdi") + } }; LocalizationService.Save(parentItem); _parentItemGuidId = parentItem.Key; @@ -432,10 +454,10 @@ namespace Umbraco.Tests.Integration.Services var childItem = new DictionaryItem(parentItem.Key, "Child") { Translations = new List - { - new DictionaryTranslation(english, "ChildValue"), - new DictionaryTranslation(danish, "BørnVærdi") - } + { + new DictionaryTranslation(languageEnGb, "ChildValue"), + new DictionaryTranslation(languageDaDk, "BørnVærdi") + } }; LocalizationService.Save(childItem); _childItemGuidId = childItem.Key; diff --git a/src/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj b/src/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj index 64ae0cf084..84e0eebd18 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj +++ b/src/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj @@ -16,6 +16,14 @@ + + + + + + + + @@ -59,4 +67,20 @@ + + + ImportResources.resx + True + True + + + + + + Designer + ImportResources.Designer.cs + ResXFileCodeGenerator + + + diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Tests.Common/Builders/LanguageBuilderTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Tests.Common/Builders/LanguageBuilderTests.cs index b4dfaef6e3..1efd9ddc01 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Tests.Common/Builders/LanguageBuilderTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Tests.Common/Builders/LanguageBuilderTests.cs @@ -15,6 +15,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Tests.Common.Builders var builder = new LanguageBuilder(); var expected = CultureInfo.GetCultureInfo("en-GB"); + // Act var language = builder .WithCultureInfo(expected.Name) diff --git a/src/Umbraco.Tests/Services/Importing/Dictionary-Package.xml b/src/Umbraco.Tests/Services/Importing/Dictionary-Package.xml index 6fa5a3d15f..18ff588d64 100644 --- a/src/Umbraco.Tests/Services/Importing/Dictionary-Package.xml +++ b/src/Umbraco.Tests/Services/Importing/Dictionary-Package.xml @@ -30,7 +30,7 @@ - + - \ No newline at end of file + diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index f4ef9f26e2..eafcac59da 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -33,10 +33,10 @@ - - true - true - + + true + true + true full @@ -171,7 +171,6 @@ - @@ -486,4 +485,4 @@ - + \ No newline at end of file