diff --git a/MoreLinq.Test/Comparer.cs b/MoreLinq.Test/Comparer.cs deleted file mode 100644 index 7f9f26c29..000000000 --- a/MoreLinq.Test/Comparer.cs +++ /dev/null @@ -1,45 +0,0 @@ -#region License and Terms -// MoreLINQ - Extensions to LINQ to Objects -// Copyright (c) 2017 Atif Aziz. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#endregion - -namespace MoreLinq.Test -{ - using System; - using System.Collections.Generic; - - sealed class Comparer - { - /// - /// Creates an given a - /// . - /// - - public static IComparer Create(Func compare) => - new DelegatingComparer(compare); - - sealed class DelegatingComparer : IComparer - { - readonly Func _comparer; - - public DelegatingComparer(Func comparer) - { - _comparer = comparer ?? throw new ArgumentNullException(nameof(comparer)); - } - - public int Compare(T? x, T? y) => _comparer(x, y); - } - } -} diff --git a/MoreLinq.Test/MoreLinq.Test.csproj b/MoreLinq.Test/MoreLinq.Test.csproj index fe1ab869c..8c2a32e67 100644 --- a/MoreLinq.Test/MoreLinq.Test.csproj +++ b/MoreLinq.Test/MoreLinq.Test.csproj @@ -72,7 +72,6 @@ - diff --git a/MoreLinq.Test/OrderByTest.cs b/MoreLinq.Test/OrderByTest.cs index cb6f8bf1d..4fa256d1f 100644 --- a/MoreLinq.Test/OrderByTest.cs +++ b/MoreLinq.Test/OrderByTest.cs @@ -19,6 +19,7 @@ namespace MoreLinq.Test { using System.Collections.Generic; using NUnit.Framework; + using Delegate = Delegating.Delegate; /// /// Verify the behavior of the OrderBy/ThenBy operators @@ -47,7 +48,7 @@ public void TestOrderBySelectorPreserved() } static readonly IComparer NumericStringComparer = - Comparer.Create((string? a, string? b) => + Delegate.Comparer((string? a, string? b) => (a, b) switch { (null, null) => 0, diff --git a/MoreLinq.Test/RankTest.cs b/MoreLinq.Test/RankTest.cs index 6965c1226..13eec0194 100644 --- a/MoreLinq.Test/RankTest.cs +++ b/MoreLinq.Test/RankTest.cs @@ -19,6 +19,7 @@ namespace MoreLinq.Test { using System; using NUnit.Framework; + using Delegate = Delegating.Delegate; /// /// Verify the behavior of the Rank operator @@ -172,8 +173,8 @@ public void TestRankCustomComparer() var ordinals = Enumerable.Range(1, count); var sequence = ordinals.Select( x => new DateTime(2010,x,20-x) ); // invert the CompareTo operation to Rank in reverse order (ascending to descending) - var resultA = sequence.AsTestingSequence().Rank(Comparer.Create((a, b) => -a.CompareTo(b))); - var resultB = sequence.AsTestingSequence().RankBy(x => x.Day, Comparer.Create((a, b) => -a.CompareTo(b))); + var resultA = sequence.AsTestingSequence().Rank(Delegate.Comparer((a, b) => -a.CompareTo(b))); + var resultB = sequence.AsTestingSequence().RankBy(x => x.Day, Delegate.Comparer((a, b) => -a.CompareTo(b))); Assert.That(resultA, Is.EqualTo(ordinals)); Assert.That(resultB, Is.EqualTo(ordinals.Reverse()));