WIP - new IEntityXmlSerializer, IPackageCreation, PackageActionRunner, large refactor of entity serialization, no more IPackagingService.Export methods, ports legacy package creation code to new IPackageCreation, more more ExportEventArgs (makes no sense)
This commit is contained in:
@@ -6,6 +6,7 @@ using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
@@ -66,7 +67,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
|
||||
var domainCache = new DomainCache(ServiceContext.DomainService, DefaultCultureAccessor);
|
||||
var publishedShapshot = new Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedSnapshot(
|
||||
new PublishedContentCache(xmlStore, domainCache, cacheProvider, globalSettings, new SiteDomainHelper(), ContentTypesCache, null, null),
|
||||
new PublishedMediaCache(xmlStore, ServiceContext.MediaService, ServiceContext.UserService, cacheProvider, ContentTypesCache),
|
||||
new PublishedMediaCache(xmlStore, ServiceContext.MediaService, ServiceContext.UserService, cacheProvider, ContentTypesCache, Factory.GetInstance<IEntityXmlSerializer>()),
|
||||
new PublishedMemberCache(null, cacheProvider, Current.Services.MemberService, ContentTypesCache),
|
||||
domainCache);
|
||||
var publishedSnapshotService = new Mock<IPublishedSnapshotService>();
|
||||
|
||||
@@ -15,6 +15,7 @@ using Umbraco.Tests.Testing;
|
||||
using Current = Umbraco.Web.Composing.Current;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.PublishedContent;
|
||||
|
||||
namespace Umbraco.Tests.Cache.PublishedCache
|
||||
@@ -74,7 +75,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
|
||||
var mChild2 = MakeNewMedia("Child2", mType, user, mRoot2.Id);
|
||||
|
||||
var ctx = GetUmbracoContext("/test");
|
||||
var cache = new PublishedMediaCache(new XmlStore((XmlDocument) null, null, null, null), ServiceContext.MediaService, ServiceContext.UserService, new StaticCacheProvider(), ContentTypesCache);
|
||||
var cache = new PublishedMediaCache(new XmlStore((XmlDocument) null, null, null, null), ServiceContext.MediaService, ServiceContext.UserService, new StaticCacheProvider(), ContentTypesCache, Factory.GetInstance<IEntityXmlSerializer>());
|
||||
var roots = cache.GetAtRoot();
|
||||
Assert.AreEqual(2, roots.Count());
|
||||
Assert.IsTrue(roots.Select(x => x.Id).ContainsAll(new[] {mRoot1.Id, mRoot2.Id}));
|
||||
@@ -92,7 +93,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
|
||||
|
||||
//var publishedMedia = PublishedMediaTests.GetNode(mRoot.Id, GetUmbracoContext("/test", 1234));
|
||||
var umbracoContext = GetUmbracoContext("/test");
|
||||
var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null), Current.Services.MediaService, Current.Services.UserService, new StaticCacheProvider(), ContentTypesCache);
|
||||
var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null), Current.Services.MediaService, Current.Services.UserService, new StaticCacheProvider(), ContentTypesCache, Factory.GetInstance<IEntityXmlSerializer>());
|
||||
var publishedMedia = cache.GetById(mRoot.Id);
|
||||
Assert.IsNotNull(publishedMedia);
|
||||
|
||||
@@ -203,7 +204,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
|
||||
|
||||
var result = new SearchResult("1234", 1, 1, () => fields.ToDictionary(x => x.Key, x => new List<string> { x.Value }));
|
||||
|
||||
var store = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null), ServiceContext.MediaService, ServiceContext.UserService, new StaticCacheProvider(), ContentTypesCache);
|
||||
var store = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null), ServiceContext.MediaService, ServiceContext.UserService, new StaticCacheProvider(), ContentTypesCache, Factory.GetInstance<IEntityXmlSerializer>());
|
||||
var doc = store.CreateFromCacheValues(store.ConvertFromSearchResult(result));
|
||||
|
||||
DoAssert(doc, 1234, key, 0, 0, "/media/test.jpg", "Image", 23, "Shannon", "Shannon", 0, 0, "-1,1234", DateTime.Parse("2012-07-17T10:34:09"), DateTime.Parse("2012-07-16T10:34:09"), 2);
|
||||
@@ -219,7 +220,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
|
||||
var xmlDoc = GetMediaXml();
|
||||
((XmlElement)xmlDoc.DocumentElement.FirstChild).SetAttribute("key", key.ToString());
|
||||
var navigator = xmlDoc.SelectSingleNode("/root/Image").CreateNavigator();
|
||||
var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null), ServiceContext.MediaService, ServiceContext.UserService, new StaticCacheProvider(), ContentTypesCache);
|
||||
var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null), ServiceContext.MediaService, ServiceContext.UserService, new StaticCacheProvider(), ContentTypesCache, Factory.GetInstance<IEntityXmlSerializer>());
|
||||
var doc = cache.CreateFromCacheValues(cache.ConvertFromXPathNavigator(navigator, true));
|
||||
|
||||
DoAssert(doc, 2000, key, 0, 2, "image1", "Image", 23, "Shannon", "Shannon", 33, 33, "-1,2000", DateTime.Parse("2012-06-12T14:13:17"), DateTime.Parse("2012-07-20T18:50:43"), 1);
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
using System.Xml.Linq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
@@ -29,7 +31,7 @@ namespace Umbraco.Tests.Models
|
||||
var urlName = content.GetUrlSegment(new[]{new DefaultUrlSegmentProvider() });
|
||||
|
||||
// Act
|
||||
XElement element = content.ToXml();
|
||||
XElement element = content.ToXml(Factory.GetInstance<IEntityXmlSerializer>());
|
||||
|
||||
// Assert
|
||||
Assert.That(element, Is.Not.Null);
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Xml.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
@@ -50,7 +51,7 @@ namespace Umbraco.Tests.Models
|
||||
var urlName = media.GetUrlSegment(new[] { new DefaultUrlSegmentProvider() });
|
||||
|
||||
// Act
|
||||
XElement element = media.ToXml();
|
||||
XElement element = media.ToXml(Factory.GetInstance<IEntityXmlSerializer>());
|
||||
|
||||
// Assert
|
||||
Assert.That(element, Is.Not.Null);
|
||||
|
||||
@@ -152,7 +152,8 @@ namespace Umbraco.Tests.PublishedContent
|
||||
new TestDefaultCultureAccessor(),
|
||||
dataSource,
|
||||
globalSettings,
|
||||
new SiteDomainHelper());
|
||||
new SiteDomainHelper(),
|
||||
Mock.Of<IEntityXmlSerializer>());
|
||||
|
||||
// get a snapshot, get a published content
|
||||
var snapshot = snapshotService.CreatePublishedSnapshot(previewToken: null);
|
||||
|
||||
@@ -22,6 +22,7 @@ using Umbraco.Tests.Testing;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Tests.PublishedContent
|
||||
{
|
||||
@@ -66,7 +67,9 @@ namespace Umbraco.Tests.PublishedContent
|
||||
/// <returns></returns>
|
||||
internal IPublishedContent GetNode(int id, UmbracoContext umbracoContext)
|
||||
{
|
||||
var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null), Current.Services.MediaService, Current.Services.UserService, new StaticCacheProvider(), ContentTypesCache);
|
||||
var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null),
|
||||
ServiceContext.MediaService, ServiceContext.UserService, new StaticCacheProvider(), ContentTypesCache,
|
||||
Factory.GetInstance<IEntityXmlSerializer>());
|
||||
var doc = cache.GetById(id);
|
||||
Assert.IsNotNull(doc);
|
||||
return doc;
|
||||
@@ -123,7 +126,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
var searcher = indexer.GetSearcher();
|
||||
var ctx = GetUmbracoContext("/test");
|
||||
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
|
||||
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new StaticCacheProvider(), ContentTypesCache, Factory.GetInstance<IEntityXmlSerializer>());
|
||||
|
||||
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
|
||||
var publishedMedia = cache.GetById(1111);
|
||||
@@ -153,7 +156,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
var searcher = indexer.GetSearcher();
|
||||
var ctx = GetUmbracoContext("/test");
|
||||
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
|
||||
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new StaticCacheProvider(), ContentTypesCache, Factory.GetInstance<IEntityXmlSerializer>());
|
||||
|
||||
//ensure it is found
|
||||
var publishedMedia = cache.GetById(3113);
|
||||
@@ -200,7 +203,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
var searcher = indexer.GetSearcher();
|
||||
var ctx = GetUmbracoContext("/test");
|
||||
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
|
||||
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new StaticCacheProvider(), ContentTypesCache, Factory.GetInstance<IEntityXmlSerializer>());
|
||||
|
||||
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
|
||||
var publishedMedia = cache.GetById(1111);
|
||||
@@ -228,7 +231,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
var searcher = indexer.GetSearcher();
|
||||
var ctx = GetUmbracoContext("/test");
|
||||
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
|
||||
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new StaticCacheProvider(), ContentTypesCache, Factory.GetInstance<IEntityXmlSerializer>());
|
||||
|
||||
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
|
||||
var publishedMedia = cache.GetById(1111);
|
||||
@@ -256,7 +259,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
var searcher = indexer.GetSearcher();
|
||||
var ctx = GetUmbracoContext("/test");
|
||||
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
|
||||
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new StaticCacheProvider(), ContentTypesCache, Factory.GetInstance<IEntityXmlSerializer>());
|
||||
|
||||
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
|
||||
var publishedMedia = cache.GetById(1111);
|
||||
@@ -285,7 +288,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
var ctx = GetUmbracoContext("/test");
|
||||
var searcher = indexer.GetSearcher();
|
||||
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
|
||||
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new StaticCacheProvider(), ContentTypesCache, Factory.GetInstance<IEntityXmlSerializer>());
|
||||
|
||||
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
|
||||
var publishedMedia = cache.GetById(3113);
|
||||
@@ -311,7 +314,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
var ctx = GetUmbracoContext("/test");
|
||||
var searcher = indexer.GetSearcher();
|
||||
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
|
||||
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new StaticCacheProvider(), ContentTypesCache, Factory.GetInstance<IEntityXmlSerializer>());
|
||||
|
||||
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
|
||||
var publishedMedia = cache.GetById(3113);
|
||||
@@ -479,7 +482,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
</Image>");
|
||||
var node = xml.DescendantsAndSelf("Image").Single(x => (int)x.Attribute("id") == nodeId);
|
||||
|
||||
var publishedMedia = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null), ServiceContext.MediaService, ServiceContext.UserService, new StaticCacheProvider(), ContentTypesCache);
|
||||
var publishedMedia = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null), ServiceContext.MediaService, ServiceContext.UserService, new StaticCacheProvider(), ContentTypesCache, Factory.GetInstance<IEntityXmlSerializer>());
|
||||
|
||||
var nav = node.CreateNavigator();
|
||||
|
||||
@@ -499,7 +502,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
var errorXml = new XElement("error", string.Format("No media is maching '{0}'", 1234));
|
||||
var nav = errorXml.CreateNavigator();
|
||||
|
||||
var publishedMedia = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null), ServiceContext.MediaService, ServiceContext.UserService, new StaticCacheProvider(), ContentTypesCache);
|
||||
var publishedMedia = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null), ServiceContext.MediaService, ServiceContext.UserService, new StaticCacheProvider(), ContentTypesCache, Factory.GetInstance<IEntityXmlSerializer>());
|
||||
var converted = publishedMedia.ConvertFromXPathNodeIterator(nav.Select("/"), 1234);
|
||||
|
||||
Assert.IsNull(converted);
|
||||
|
||||
@@ -95,7 +95,8 @@ namespace Umbraco.Tests.Scoping
|
||||
documentRepository, mediaRepository, memberRepository,
|
||||
DefaultCultureAccessor,
|
||||
new DatabaseDataSource(),
|
||||
Factory.GetInstance<IGlobalSettings>(), new SiteDomainHelper());
|
||||
Factory.GetInstance<IGlobalSettings>(), new SiteDomainHelper(),
|
||||
Factory.GetInstance<IEntityXmlSerializer>());
|
||||
}
|
||||
|
||||
protected UmbracoContext GetUmbracoContextNu(string url, int templateId = 1234, RouteData routeData = null, bool setSingleton = false, IUmbracoSettingsSection umbracoSettings = null, IEnumerable<IUrlProvider> urlProviders = null)
|
||||
|
||||
@@ -67,7 +67,8 @@ namespace Umbraco.Tests.Services
|
||||
documentRepository, mediaRepository, memberRepository,
|
||||
DefaultCultureAccessor,
|
||||
new DatabaseDataSource(),
|
||||
Factory.GetInstance<IGlobalSettings>(), new SiteDomainHelper());
|
||||
Factory.GetInstance<IGlobalSettings>(), new SiteDomainHelper(),
|
||||
Factory.GetInstance<IEntityXmlSerializer>());
|
||||
}
|
||||
|
||||
public class LocalServerMessenger : ServerMessengerBase
|
||||
|
||||
101
src/Umbraco.Tests/Services/EntityXmlSerializerTests.cs
Normal file
101
src/Umbraco.Tests/Services/EntityXmlSerializerTests.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.Services.Importing;
|
||||
using Umbraco.Tests.Testing;
|
||||
|
||||
namespace Umbraco.Tests.Services
|
||||
{
|
||||
[TestFixture]
|
||||
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
|
||||
public class EntityXmlSerializerTests : TestWithSomeContentBase
|
||||
{
|
||||
private IEntityXmlSerializer Serializer => Factory.GetInstance<IEntityXmlSerializer>();
|
||||
|
||||
[Test]
|
||||
public void Can_Export_Macro()
|
||||
{
|
||||
// Arrange
|
||||
var macro = new Macro("test1", "Test", "~/views/macropartials/test.cshtml", MacroTypes.PartialView);
|
||||
ServiceContext.MacroService.Save(macro);
|
||||
|
||||
// Act
|
||||
var element = Serializer.Serialize(macro);
|
||||
|
||||
// Assert
|
||||
Assert.That(element, Is.Not.Null);
|
||||
Assert.That(element.Element("name").Value, Is.EqualTo("Test"));
|
||||
Assert.That(element.Element("alias").Value, Is.EqualTo("test1"));
|
||||
Debug.Print(element.ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Export_DictionaryItems()
|
||||
{
|
||||
// Arrange
|
||||
CreateDictionaryData();
|
||||
var dictionaryItem = ServiceContext.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 void Can_Export_Languages()
|
||||
{
|
||||
// Arrange
|
||||
var languageNbNo = new Language("nb-NO") { CultureName = "Norwegian" };
|
||||
ServiceContext.LocalizationService.Save(languageNbNo);
|
||||
|
||||
var languageEnGb = new Language("en-GB") { CultureName = "English (United Kingdom)" };
|
||||
ServiceContext.LocalizationService.Save(languageEnGb);
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
private void CreateDictionaryData()
|
||||
{
|
||||
var languageNbNo = new Language("nb-NO") { CultureName = "nb-NO" };
|
||||
ServiceContext.LocalizationService.Save(languageNbNo);
|
||||
|
||||
var languageEnGb = new Language("en-GB") { CultureName = "en-GB" };
|
||||
ServiceContext.LocalizationService.Save(languageEnGb);
|
||||
|
||||
var parentItem = new DictionaryItem("Parent");
|
||||
var parentTranslations = new List<IDictionaryTranslation>
|
||||
{
|
||||
new DictionaryTranslation(languageNbNo, "ForelderVerdi"),
|
||||
new DictionaryTranslation(languageEnGb, "ParentValue")
|
||||
};
|
||||
parentItem.Translations = parentTranslations;
|
||||
ServiceContext.LocalizationService.Save(parentItem);
|
||||
|
||||
var childItem = new DictionaryItem(parentItem.Key, "Child");
|
||||
var childTranslations = new List<IDictionaryTranslation>
|
||||
{
|
||||
new DictionaryTranslation(languageNbNo, "BarnVerdi"),
|
||||
new DictionaryTranslation(languageEnGb, "ChildValue")
|
||||
};
|
||||
childItem.Translations = childTranslations;
|
||||
ServiceContext.LocalizationService.Save(childItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ using Umbraco.Core.Composing.Composers;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.Testing;
|
||||
|
||||
namespace Umbraco.Tests.Services.Importing
|
||||
@@ -416,11 +417,12 @@ namespace Umbraco.Tests.Services.Importing
|
||||
string strXml = ImportResources.SingleDocType;
|
||||
var docTypeElement = XElement.Parse(strXml);
|
||||
var packagingService = ServiceContext.PackagingService;
|
||||
var serializer = Factory.GetInstance<IEntityXmlSerializer>();
|
||||
|
||||
// Act
|
||||
var contentTypes = packagingService.ImportContentTypes(docTypeElement);
|
||||
var contentType = contentTypes.FirstOrDefault();
|
||||
var element = packagingService.Export(contentType);
|
||||
var element = serializer.Serialize(contentType);
|
||||
|
||||
// Assert
|
||||
Assert.That(element, Is.Not.Null);
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Packaging;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Implement;
|
||||
using Umbraco.Tests.Services.Importing;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
|
||||
@@ -20,59 +13,7 @@ namespace Umbraco.Tests.Services
|
||||
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
|
||||
public class PackagingServiceTests : TestWithSomeContentBase
|
||||
{
|
||||
[Test]
|
||||
public void PackagingService_Can_Export_Macro()
|
||||
{
|
||||
// Arrange
|
||||
var macro = new Macro("test1", "Test", "~/views/macropartials/test.cshtml", MacroTypes.PartialView);
|
||||
ServiceContext.MacroService.Save(macro);
|
||||
|
||||
// Act
|
||||
var element = ServiceContext.PackagingService.Export(macro);
|
||||
|
||||
// Assert
|
||||
Assert.That(element, Is.Not.Null);
|
||||
Assert.That(element.Element("name").Value, Is.EqualTo("Test"));
|
||||
Assert.That(element.Element("alias").Value, Is.EqualTo("test1"));
|
||||
Debug.Print(element.ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PackagingService_Can_Export_DictionaryItems()
|
||||
{
|
||||
// Arrange
|
||||
CreateDictionaryData();
|
||||
var dictionaryItem = ServiceContext.LocalizationService.GetDictionaryItemByKey("Parent");
|
||||
|
||||
var newPackageXml = XElement.Parse(ImportResources.Dictionary_Package);
|
||||
var dictionaryItemsElement = newPackageXml.Elements("DictionaryItems").First();
|
||||
|
||||
// Act
|
||||
var xml = ServiceContext.PackagingService.Export(new []{dictionaryItem});
|
||||
|
||||
// Assert
|
||||
Assert.That(xml.ToString(), Is.EqualTo(dictionaryItemsElement.ToString()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PackagingService_Can_Export_Languages()
|
||||
{
|
||||
// Arrange
|
||||
var languageNbNo = new Language("nb-NO") { CultureName = "Norwegian" };
|
||||
ServiceContext.LocalizationService.Save(languageNbNo);
|
||||
|
||||
var languageEnGb = new Language("en-GB") { CultureName = "English (United Kingdom)" };
|
||||
ServiceContext.LocalizationService.Save(languageEnGb);
|
||||
|
||||
var newPackageXml = XElement.Parse(ImportResources.Dictionary_Package);
|
||||
var languageItemsElement = newPackageXml.Elements("Languages").First();
|
||||
|
||||
// Act
|
||||
var xml = ServiceContext.PackagingService.Export(new[] { languageNbNo, languageEnGb });
|
||||
|
||||
// Assert
|
||||
Assert.That(xml.ToString(), Is.EqualTo(languageItemsElement.ToString()));
|
||||
}
|
||||
|
||||
|
||||
private static string GetTestPackagePath(string packageName)
|
||||
{
|
||||
@@ -123,31 +64,6 @@ namespace Umbraco.Tests.Services
|
||||
Assert.IsNotNull(preInstallWarnings);
|
||||
}
|
||||
|
||||
private void CreateDictionaryData()
|
||||
{
|
||||
var languageNbNo = new Language("nb-NO") { CultureName = "nb-NO" };
|
||||
ServiceContext.LocalizationService.Save(languageNbNo);
|
||||
|
||||
var languageEnGb = new Language("en-GB") { CultureName = "en-GB" };
|
||||
ServiceContext.LocalizationService.Save(languageEnGb);
|
||||
|
||||
var parentItem = new DictionaryItem("Parent");
|
||||
var parentTranslations = new List<IDictionaryTranslation>
|
||||
{
|
||||
new DictionaryTranslation(languageNbNo, "ForelderVerdi"),
|
||||
new DictionaryTranslation(languageEnGb, "ParentValue")
|
||||
};
|
||||
parentItem.Translations = parentTranslations;
|
||||
ServiceContext.LocalizationService.Save(parentItem);
|
||||
|
||||
var childItem = new DictionaryItem(parentItem.Key, "Child");
|
||||
var childTranslations = new List<IDictionaryTranslation>
|
||||
{
|
||||
new DictionaryTranslation(languageNbNo, "BarnVerdi"),
|
||||
new DictionaryTranslation(languageEnGb, "ChildValue")
|
||||
};
|
||||
childItem.Translations = childTranslations;
|
||||
ServiceContext.LocalizationService.Save(childItem);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Packaging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
using Umbraco.Core.Persistence.Repositories;
|
||||
@@ -167,7 +168,10 @@ namespace Umbraco.Tests.TestHelpers
|
||||
GetRepo<IEntityRepository>(c)));
|
||||
|
||||
var macroService = GetLazyService<IMacroService>(factory, c => new MacroService(scopeProvider, logger, eventMessagesFactory, GetRepo<IMacroRepository>(c), GetRepo<IAuditRepository>(c)));
|
||||
var packagingService = GetLazyService<IPackagingService>(factory, c => new PackagingService(logger, contentService.Value, contentTypeService.Value, mediaService.Value, macroService.Value, dataTypeService.Value, fileService.Value, localizationService.Value, entityService.Value, userService.Value, scopeProvider, urlSegmentProviders, GetRepo<IAuditRepository>(c), GetRepo<IContentTypeRepository>(c), new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<DataEditor>()))));
|
||||
var packagingService = GetLazyService<IPackagingService>(factory, c => new PackagingService(
|
||||
logger, contentService.Value, contentTypeService.Value, macroService.Value, dataTypeService.Value, fileService.Value, localizationService.Value, entityService.Value, scopeProvider, GetRepo<IAuditRepository>(c), GetRepo<IContentTypeRepository>(c), new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<DataEditor>())),
|
||||
new PackageCreation(contentService.Value, contentTypeService.Value, dataTypeService.Value, fileService.Value, macroService.Value, localizationService.Value,
|
||||
new EntityXmlSerializer(contentService.Value, mediaService.Value, dataTypeService.Value, userService.Value, localizationService.Value, contentTypeService.Value, urlSegmentProviders), logger)));
|
||||
var relationService = GetLazyService<IRelationService>(factory, c => new RelationService(scopeProvider, logger, eventMessagesFactory, entityService.Value, GetRepo<IRelationRepository>(c), GetRepo<IRelationTypeRepository>(c)));
|
||||
var treeService = GetLazyService<IApplicationTreeService>(factory, c => new ApplicationTreeService(logger, cache, typeLoader));
|
||||
var tagService = GetLazyService<ITagService>(factory, c => new TagService(scopeProvider, logger, eventMessagesFactory, GetRepo<ITagRepository>(c)));
|
||||
|
||||
@@ -268,6 +268,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
DefaultCultureAccessor,
|
||||
Logger,
|
||||
Factory.GetInstance<IGlobalSettings>(), new SiteDomainHelper(),
|
||||
Factory.GetInstance<IEntityXmlSerializer>(),
|
||||
ContentTypesCache,
|
||||
null, true, Options.PublishedRepositoryEvents);
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace Umbraco.Tests.UI
|
||||
}
|
||||
|
||||
[TestCase(typeof(macroTasks), Constants.Applications.Settings)]
|
||||
[TestCase(typeof(CreatedPackageTasks), Constants.Applications.Packages)]
|
||||
public void Check_Assigned_Apps_For_Tasks(Type taskType, string app)
|
||||
{
|
||||
var task = (LegacyDialogTask)Activator.CreateInstance(taskType);
|
||||
|
||||
@@ -139,6 +139,7 @@
|
||||
<Compile Include="Services\ContentServicePublishBranchTests.cs" />
|
||||
<Compile Include="Services\ContentServiceTagsTests.cs" />
|
||||
<Compile Include="Services\ContentTypeServiceVariantsTests.cs" />
|
||||
<Compile Include="Services\EntityXmlSerializerTests.cs" />
|
||||
<Compile Include="Testing\Objects\TestDataSource.cs" />
|
||||
<Compile Include="Published\PublishedSnapshotTestObjects.cs" />
|
||||
<Compile Include="Published\ModelTypeTests.cs" />
|
||||
|
||||
@@ -419,11 +419,13 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
//var provider = new ScopeUnitOfWorkProvider(databaseFactory, new RepositoryFactory(Mock.Of<IServiceContainer>()));
|
||||
var scopeProvider = TestObjects.GetScopeProvider(Mock.Of<ILogger>());
|
||||
var factory = Mock.Of<IPublishedContentTypeFactory>();
|
||||
_service = new PublishedSnapshotService(svcCtx, factory, scopeProvider, cache, Enumerable.Empty<IUrlSegmentProvider>(),
|
||||
_service = new PublishedSnapshotService(svcCtx, factory, scopeProvider, cache,
|
||||
null, null,
|
||||
null, null, null,
|
||||
new TestDefaultCultureAccessor(),
|
||||
Current.Logger, TestObjects.GetGlobalSettings(), new SiteDomainHelper(), null, true, false); // no events
|
||||
Current.Logger, TestObjects.GetGlobalSettings(), new SiteDomainHelper(),
|
||||
Factory.GetInstance<IEntityXmlSerializer>(),
|
||||
null, true, false); // no events
|
||||
|
||||
var http = GetHttpContextFactory(url, routeData).HttpContext;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user