Files
Nikolaj Geisle 7aeb400fce V10: fix build warnings in test projects (#12509)
* Run code cleanup

* Dotnet format benchmarks project

* Fix up Test.Common

* Run dotnet format + manual cleanup

* Run code cleanup for unit tests

* Run dotnet format

* Fix up errors

* Manual cleanup of Unit test project

* Update tests/Umbraco.Tests.Benchmarks/HexStringBenchmarks.cs

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

* Update tests/Umbraco.Tests.Integration/Testing/TestDbMeta.cs

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

* Update tests/Umbraco.Tests.Benchmarks/TypeFinderBenchmarks.cs

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

* Update tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

* Update tests/Umbraco.Tests.Integration/Umbraco.Core/Events/EventAggregatorTests.cs

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

* Fix according to review

* Fix after merge

* Fix errors

Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk>
Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>
Co-authored-by: Zeegaan <nge@umbraco.dk>
2022-06-21 08:09:38 +02:00

94 lines
3.1 KiB
C#

// Copyright (c) Umbraco.
// See LICENSE for more details.
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Tests.Common.Builders;
using Umbraco.Cms.Tests.UnitTests.TestHelpers;
using Umbraco.Extensions;
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Models.Collections;
[TestFixture]
public class PropertyCollectionTests
{
[Test]
public void Property_Adds_Case_Insensitive_Compare()
{
var collection = new PropertyCollection
{
new Property(new PropertyType(TestHelper.ShortStringHelper, "propEditor", ValueStorageType.Nvarchar, "test")),
new Property(new PropertyType(TestHelper.ShortStringHelper, "propEditor", ValueStorageType.Nvarchar, "Test")),
};
Assert.AreEqual(1, collection.Count);
}
[Test]
public void Property_Contains_Case_Insensitive_Compare()
{
var collection = new PropertyCollection
{
new Property(new PropertyType(TestHelper.ShortStringHelper, "propEditor", ValueStorageType.Nvarchar, "test")),
};
Assert.IsTrue(collection.Contains("Test"));
}
[Test]
public void SimpleOrder_Returns_Null_On_FirstOrDefault_When_Empty()
{
var orders = new SimpleOrder();
var item = orders.FirstOrDefault();
Assert.That(item == null, Is.True);
}
[Test]
public void PropertyCollection_Returns_Null_On_FirstOrDefault_When_Empty()
{
var list = new List<Property>();
var collection = new PropertyCollection(list);
var first = collection.FirstOrDefault();
var second = collection.FirstOrDefault(x => x.Alias.InvariantEquals("Test"));
Assert.That(first, Is.Null);
Assert.That(first == null, Is.True);
Assert.That(second == null, Is.True);
}
[Test]
public void PropertyTypeCollection_Returns_Null_On_FirstOrDefault_When_Empty()
{
var list = new List<PropertyType>();
var collection = new PropertyTypeCollection(false, list);
Assert.That(collection.FirstOrDefault(), Is.Null);
Assert.That(collection.FirstOrDefault(x => x.Alias.InvariantEquals("Test")) == null, Is.True);
}
[Test]
public void PropertyGroupCollection_Returns_Null_On_FirstOrDefault_When_Empty()
{
var list = new List<PropertyGroup>();
var collection = new PropertyGroupCollection(list);
Assert.That(collection.FirstOrDefault(), Is.Null);
Assert.That(collection.FirstOrDefault(x => x.Name.InvariantEquals("Test")) == null, Is.True);
}
[Test]
public void PropertyGroups_Collection_FirstOrDefault_Returns_Null()
{
var contentType = ContentTypeBuilder.CreateTextPageContentType();
Assert.That(contentType.PropertyGroups, Is.Not.Null);
Assert.That(contentType.PropertyGroups.FirstOrDefault(x => x.Name.InvariantEquals("Content")) == null, Is.False);
Assert.That(contentType.PropertyGroups.FirstOrDefault(x => x.Name.InvariantEquals("Test")) == null, Is.True);
Assert.That(contentType.PropertyGroups.Any(x => x.Name.InvariantEquals("Test")), Is.False);
}
}