mirror of https://github.com/Squidex/squidex.git
5 changed files with 121 additions and 3 deletions
@ -0,0 +1,44 @@ |
|||
// ==========================================================================
|
|||
// InvariantPartitionTests.cs
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex Group
|
|||
// All rights reserved.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using Xunit; |
|||
|
|||
// ReSharper disable RedundantCast
|
|||
// ReSharper disable UseCollectionCountProperty
|
|||
|
|||
namespace Squidex.Core |
|||
{ |
|||
public sealed class InvariantPartitionTests |
|||
{ |
|||
[Fact] |
|||
public void Should_provide_single_value() |
|||
{ |
|||
var sut = InvariantPartitioning.Instance; |
|||
|
|||
Assert.Equal(1, sut.Count); |
|||
|
|||
Assert.Equal(sut.Master, ((IEnumerable<IFieldPartitionItem>)sut).SingleOrDefault()); |
|||
Assert.Equal(sut.Master, ((IEnumerable)sut).OfType<IFieldPartitionItem>().SingleOrDefault()); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_provide_master() |
|||
{ |
|||
var sut = InvariantPartitioning.Instance; |
|||
|
|||
Assert.Equal("iv", sut.Master.Key); |
|||
Assert.Equal("Invariant", sut.Master.Name); |
|||
|
|||
Assert.False(sut.Master.Fallback.Any()); |
|||
Assert.False(sut.Master.IsOptional); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
// ==========================================================================
|
|||
// PartitioningTests.cs
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex Group
|
|||
// All rights reserved.
|
|||
// ==========================================================================
|
|||
|
|||
using Xunit; |
|||
|
|||
namespace Squidex.Core |
|||
{ |
|||
public sealed class PartitioningTests |
|||
{ |
|||
[Fact] |
|||
public void Should_provide_invariant_instance() |
|||
{ |
|||
Assert.Equal("invariant", Partitioning.Invariant.Key); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_provide_language_instance() |
|||
{ |
|||
Assert.Equal("language", Partitioning.Language.Key); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_make_correct_equal_comparisons() |
|||
{ |
|||
var partitioning1a = new Partitioning("partitioning1"); |
|||
var partitioning1b = new Partitioning("partitioning1"); |
|||
var partitioning2a = new Partitioning("partitioning2"); |
|||
|
|||
Assert.True(partitioning1a.Equals(partitioning1b)); |
|||
|
|||
Assert.False(partitioning1a.Equals(partitioning2a)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_make_correct_object_equal_comparisons() |
|||
{ |
|||
object partitioning1a = new Partitioning("partitioning1"); |
|||
object partitioning1b = new Partitioning("partitioning1"); |
|||
object partitioning2a = new Partitioning("partitioning2"); |
|||
|
|||
Assert.True(partitioning1a.Equals(partitioning1b)); |
|||
|
|||
Assert.False(partitioning1a.Equals(partitioning2a)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_provide_correct_hash_codes() |
|||
{ |
|||
var partitioning1a = new Partitioning("partitioning1"); |
|||
var partitioning1b = new Partitioning("partitioning1"); |
|||
var partitioning2a = new Partitioning("partitioning2"); |
|||
|
|||
Assert.Equal(partitioning1a.GetHashCode(), partitioning1b.GetHashCode()); |
|||
|
|||
Assert.NotEqual(partitioning1a.GetHashCode(), partitioning2a.GetHashCode()); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue