Files
Umbraco-CMS/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Models/LanguageTests.cs
Paul Johnson 00133e880d Move test projects from src/ to tests/ (#11357)
* Update gitignore

* Move csproj

* Update project references

* Update solutions

* Update build scripts

* Tests used to share editorconfig with projects in src

* Fix broken tests.

* Stop copying around .editorconfig

merged root one with linting

* csharp_style_expression_bodied -> suggestion

* Move StyleCop rulesets to matching directories and update shared build properties

* Remove legacy build files, update NuGet.cofig and solution files

* Restore myget source

* Clean up .gitignore

* Update .gitignore

* Move new test classes to tests after merge

* Gitignore + nuget config

* Move new test

Co-authored-by: Ronald Barendse <ronald@barend.se>
2021-10-18 08:14:04 +01:00

55 lines
1.7 KiB
C#

// Copyright (c) Umbraco.
// See LICENSE for more details.
using System.Reflection;
using Newtonsoft.Json;
using NUnit.Framework;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Tests.Common.Builders;
using Umbraco.Cms.Tests.Common.Builders.Extensions;
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Models
{
[TestFixture]
public class LanguageTests
{
private LanguageBuilder _builder = new LanguageBuilder();
[SetUp]
public void SetUp() => _builder = new LanguageBuilder();
[Test]
public void Can_Deep_Clone()
{
ILanguage item = _builder
.WithId(1)
.Build();
var clone = (Language)item.DeepClone();
Assert.AreNotSame(clone, item);
Assert.AreEqual(clone, item);
Assert.AreEqual(clone.CreateDate, item.CreateDate);
Assert.AreEqual(clone.CultureName, item.CultureName);
Assert.AreEqual(clone.Id, item.Id);
Assert.AreEqual(clone.IsoCode, item.IsoCode);
Assert.AreEqual(clone.Key, item.Key);
Assert.AreEqual(clone.UpdateDate, item.UpdateDate);
// This double verifies by reflection
PropertyInfo[] allProps = clone.GetType().GetProperties();
foreach (PropertyInfo propertyInfo in allProps)
{
Assert.AreEqual(propertyInfo.GetValue(clone, null), propertyInfo.GetValue(item, null));
}
}
[Test]
public void Can_Serialize_Without_Error()
{
ILanguage item = _builder.Build();
Assert.DoesNotThrow(() => JsonConvert.SerializeObject(item));
}
}
}