Refactors the serialization of the content data that is stored in the nucache table. This had to change because we need to resolve content type data in order to check if the property should be compressed and we cannot do that data lookup while the data is being processed since we get an open data reader exception. This is fixed now by using a serializer factory instead so the Create method can do any initialization needed prior to running any serialization operation. Renames a few things so we dont have ContentNested (whatever that meant )
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
using NUnit.Framework;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Web.PublishedCache.NuCache.DataSource;
|
||||
|
||||
namespace Umbraco.Tests.PublishedContent
|
||||
@@ -16,10 +14,10 @@ namespace Umbraco.Tests.PublishedContent
|
||||
public void Ensure_Same_Results()
|
||||
{
|
||||
var jsonSerializer = new JsonContentNestedDataSerializer();
|
||||
var msgPackSerializer = new MsgPackContentNestedDataSerializer();
|
||||
var msgPackSerializer = new MsgPackContentNestedDataSerializer(Mock.Of<IPropertyCompressionOptions>());
|
||||
|
||||
var now = DateTime.Now;
|
||||
var content = new ContentNestedData
|
||||
var content = new ContentCacheDataModel
|
||||
{
|
||||
PropertyData = new Dictionary<string, PropertyData[]>
|
||||
{
|
||||
@@ -55,14 +53,14 @@ namespace Umbraco.Tests.PublishedContent
|
||||
UrlSegment = "home"
|
||||
};
|
||||
|
||||
var json = jsonSerializer.Serialize(1, content);
|
||||
var msgPack = msgPackSerializer.Serialize(1, content);
|
||||
var json = jsonSerializer.Serialize(1, content).StringData;
|
||||
var msgPack = msgPackSerializer.Serialize(1, content).ByteData;
|
||||
|
||||
Console.WriteLine(json);
|
||||
Console.WriteLine(msgPackSerializer.ToJson(msgPack));
|
||||
|
||||
var jsonContent = jsonSerializer.Deserialize(1, json);
|
||||
var msgPackContent = msgPackSerializer.Deserialize(1, msgPack);
|
||||
var jsonContent = jsonSerializer.Deserialize(1, json, null);
|
||||
var msgPackContent = msgPackSerializer.Deserialize(1, null, msgPack);
|
||||
|
||||
|
||||
CollectionAssert.AreEqual(jsonContent.CultureData.Keys, msgPackContent.CultureData.Keys);
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
private ContentType _contentTypeInvariant;
|
||||
private ContentType _contentTypeVariant;
|
||||
private TestDataSource _source;
|
||||
private IContentNestedDataSerializer _contentNestedDataSerializer;
|
||||
private IContentCacheDataSerializerFactory _contentNestedDataSerializerFactory;
|
||||
|
||||
[TearDown]
|
||||
public void Teardown()
|
||||
@@ -135,7 +135,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
// create a data source for NuCache
|
||||
_source = new TestDataSource(kits());
|
||||
_contentNestedDataSerializer = new JsonContentNestedDataSerializer();
|
||||
_contentNestedDataSerializerFactory = new JsonContentNestedDataSerializerFactory();
|
||||
|
||||
// at last, create the complete NuCache snapshot service!
|
||||
var options = new PublishedSnapshotServiceOptions { IgnoreLocalDb = true };
|
||||
@@ -158,7 +158,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
Mock.Of<IEntityXmlSerializer>(),
|
||||
Mock.Of<IPublishedModelFactory>(),
|
||||
new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider() }),
|
||||
_contentNestedDataSerializer);
|
||||
_contentNestedDataSerializerFactory);
|
||||
|
||||
// invariant is the current default
|
||||
_variationAccesor.VariationContext = new VariationContext();
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
{
|
||||
private IPublishedSnapshotService _snapshotService;
|
||||
private IVariationContextAccessor _variationAccesor;
|
||||
private IContentNestedDataSerializer _contentNestedDataSerializer;
|
||||
private IContentCacheDataSerializerFactory _contentNestedDataSerializerFactory;
|
||||
private ContentType _contentType;
|
||||
private PropertyType _propertyType;
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
// create a data source for NuCache
|
||||
var dataSource = new TestDataSource(kit);
|
||||
_contentNestedDataSerializer = new JsonContentNestedDataSerializer();
|
||||
_contentNestedDataSerializerFactory = new JsonContentNestedDataSerializerFactory();
|
||||
|
||||
var runtime = Mock.Of<IRuntimeState>();
|
||||
Mock.Get(runtime).Setup(x => x.Level).Returns(RuntimeLevel.Run);
|
||||
@@ -204,7 +204,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
Mock.Of<IEntityXmlSerializer>(),
|
||||
Mock.Of<IPublishedModelFactory>(),
|
||||
new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider() }),
|
||||
_contentNestedDataSerializer);
|
||||
_contentNestedDataSerializerFactory);
|
||||
|
||||
// invariant is the current default
|
||||
_variationAccesor.VariationContext = new VariationContext();
|
||||
|
||||
Reference in New Issue
Block a user