* starts cleaning up old test project, removing ones we'll never convert, moves new test to where it should be. * Makes ContentNodeKit immutable properties, moves first nucache tests over * Gets the Nucache unit tests working and refactors a bit to use builder pattern for models. * Migrates first xml based cache test to use nucache. * Migrates a bunch more * Migrates remaining tests for PublishedContentTests * Moves PublishedRouterTests * Moves PublishedContentExtensionTests * Moves more tests. * committing wip * committing wip * Gets PublishedContentLanguageVariantTests converted and working. * Fixes DataTable ext method and moves PublishedContentDataTableTests * Moves PublishedMediaTests * wip - moving EntityXmlSerializerTests * Moves more tests * moves more tests * moves more tests * Move another test * Moves more tests * Fix test * move another test * Moves more tests * Moves more tests * Moves more tests * wip before merge * More tests * More tests * More tests * More tests * More tests * More tests * Cleanup and moving classes. * Remove unused code * Fixed failing tests, due to new null checks, that did not exist in v8 * Avoid breaking changes * Unbreak more things, even that it the old solution was crazy.. * Fixed bug where ordering of stream readings was changed.. * cleanup Co-authored-by: Bjarke Berg <mail@bergmania.dk>
65 lines
2.0 KiB
C#
65 lines
2.0 KiB
C#
using Newtonsoft.Json;
|
|
using NUnit.Framework;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Umbraco.Cms.Infrastructure.Serialization;
|
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Infrastructure.Serialization
|
|
{
|
|
[TestFixture]
|
|
public class AutoInterningStringConverterTests
|
|
{
|
|
[Test]
|
|
public void Intern_Property_String()
|
|
{
|
|
var str1 = "Hello";
|
|
var obj = new Test
|
|
{
|
|
Name = str1 + Guid.NewGuid()
|
|
};
|
|
|
|
// ensure the raw value is not interned
|
|
Assert.IsNull(string.IsInterned(obj.Name));
|
|
|
|
var serialized = JsonConvert.SerializeObject(obj);
|
|
obj = JsonConvert.DeserializeObject<Test>(serialized);
|
|
|
|
Assert.IsNotNull(string.IsInterned(obj.Name));
|
|
}
|
|
|
|
[Test]
|
|
public void Intern_Property_Dictionary()
|
|
{
|
|
var str1 = "key";
|
|
var obj = new Test
|
|
{
|
|
Values = new Dictionary<string, int>
|
|
{
|
|
[str1 + Guid.NewGuid()] = 0,
|
|
[str1 + Guid.NewGuid()] = 1
|
|
}
|
|
};
|
|
|
|
// ensure the raw value is not interned
|
|
Assert.IsNull(string.IsInterned(obj.Values.Keys.First()));
|
|
Assert.IsNull(string.IsInterned(obj.Values.Keys.Last()));
|
|
|
|
var serialized = JsonConvert.SerializeObject(obj);
|
|
obj = JsonConvert.DeserializeObject<Test>(serialized);
|
|
|
|
Assert.IsNotNull(string.IsInterned(obj.Values.Keys.First()));
|
|
Assert.IsNotNull(string.IsInterned(obj.Values.Keys.Last()));
|
|
}
|
|
|
|
public class Test
|
|
{
|
|
[JsonConverter(typeof(AutoInterningStringConverter))]
|
|
public string Name { get; set; }
|
|
|
|
[JsonConverter(typeof(AutoInterningStringKeyCaseInsensitiveDictionaryConverter<int>))]
|
|
public Dictionary<string, int> Values { get; set; } = new Dictionary<string, int>();
|
|
}
|
|
}
|
|
}
|