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..f8f06a2ce 100644 --- a/MoreLinq.Test/OrderByTest.cs +++ b/MoreLinq.Test/OrderByTest.cs @@ -47,14 +47,7 @@ public void TestOrderBySelectorPreserved() } static readonly IComparer NumericStringComparer = - Comparer.Create((string? a, string? b) => - (a, b) switch - { - (null, null) => 0, - (null, _) => -1, - (_, null) => 1, - var (sa, sb) => int.Parse(sa).CompareTo(int.Parse(sb)) - }); + Comparer.Create((a, b) => int.Parse(a).CompareTo(int.Parse(b))); /// /// Verify that OrderBy preserves the comparer diff --git a/MoreLinq.Test/RankTest.cs b/MoreLinq.Test/RankTest.cs index 6965c1226..381b8fd35 100644 --- a/MoreLinq.Test/RankTest.cs +++ b/MoreLinq.Test/RankTest.cs @@ -18,6 +18,7 @@ namespace MoreLinq.Test { using System; + using System.Collections.Generic; using NUnit.Framework; /// @@ -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(Comparer.Create((a, b) => -a.CompareTo(b))); + var resultB = sequence.AsTestingSequence().RankBy(x => x.Day, Comparer.Create((a, b) => -a.CompareTo(b))); Assert.That(resultA, Is.EqualTo(ordinals)); Assert.That(resultB, Is.EqualTo(ordinals.Reverse()));