Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 5.6k
[API Implementation]: Add Order and OrderDescending to Enumerable and Queryable#70525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
de029dd23d2081ea53a6c2749e41b0fa0721025faf16bfbf96a21dbffbb3a74879421b7f2c3f11382af8bd1659a885caa945a377694369ffabddd4dc0eec688b40b2fFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| using System.Collections.Generic; | ||
| using Xunit; | ||
| namespace System.Linq.Tests | ||
| { | ||
| public sealed class OrderDescendingTests : EnumerableBasedTests | ||
| { | ||
| [Fact] | ||
| public void FirstAndLastAreDuplicatesCustomComparer() | ||
| { | ||
| string[] source = { "Prakash", "Alpha", "DAN", "dan", "Prakash" }; | ||
| string[] expected = { "Prakash", "Prakash", "DAN", "dan", "Alpha" }; | ||
| Assert.Equal(expected, source.AsQueryable().OrderDescending(StringComparer.OrdinalIgnoreCase)); | ||
| } | ||
| [Fact] | ||
| public void FirstAndLastAreDuplicatesNullPassedAsComparer() | ||
| { | ||
| int[] source = { 5, 1, 3, 2, 5 }; | ||
| int[] expected = { 5, 5, 3, 2, 1 }; | ||
| Assert.Equal(expected, source.AsQueryable().OrderDescending(null)); | ||
| } | ||
| [Fact] | ||
| public void NullSource() | ||
| { | ||
| IQueryable<int> source = null; | ||
| AssertExtensions.Throws<ArgumentNullException>("source", () => source.OrderDescending()); | ||
| } | ||
| [Fact] | ||
| public void NullSourceComparer() | ||
| { | ||
| IQueryable<int> source = null; | ||
| AssertExtensions.Throws<ArgumentNullException>("source", () => source.OrderDescending(Comparer<int>.Default)); | ||
| } | ||
| [Fact] | ||
| public void OrderDescending1() | ||
| { | ||
| var count = (new int[] { 0, 1, 2 }).AsQueryable().OrderDescending().Count(); | ||
| Assert.Equal(3, count); | ||
| } | ||
| [Fact] | ||
| public void OrderDescending2() | ||
| { | ||
| var count = (new int[] { 0, 1, 2 }).AsQueryable().OrderDescending(Comparer<int>.Default).Count(); | ||
| Assert.Equal(3, count); | ||
deeprobin marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| } | ||
deeprobin marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| using System.Collections.Generic; | ||
| using Xunit; | ||
| namespace System.Linq.Tests | ||
| { | ||
deeprobin marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| public sealed class OrderTests : EnumerableBasedTests | ||
| { | ||
| [Fact] | ||
| public void FirstAndLastAreDuplicatesCustomComparer() | ||
| { | ||
| string[] source = { "Prakash", "Alpha", "dan", "DAN", "Prakash" }; | ||
| string[] expected = { "Alpha", "dan", "DAN", "Prakash", "Prakash" }; | ||
| Assert.Equal(expected, source.AsQueryable().Order(StringComparer.OrdinalIgnoreCase)); | ||
| } | ||
| [Fact] | ||
| public void FirstAndLastAreDuplicatesNullPassedAsComparer() | ||
| { | ||
| int[] source = { 5, 1, 3, 2, 5 }; | ||
| int[] expected = { 1, 2, 3, 5, 5 }; | ||
| Assert.Equal(expected, source.AsQueryable().Order(null)); | ||
| } | ||
| [Fact] | ||
| public void NullSource() | ||
| { | ||
| IQueryable<int> source = null; | ||
| AssertExtensions.Throws<ArgumentNullException>("source", () => source.Order()); | ||
| } | ||
| [Fact] | ||
| public void NullSourceComparer() | ||
| { | ||
| IQueryable<int> source = null; | ||
| AssertExtensions.Throws<ArgumentNullException>("source", () => source.Order(Comparer<int>.Default)); | ||
| } | ||
| [Fact] | ||
| public void Order1() | ||
| { | ||
| var count = (new int[] { 0, 1, 2 }).AsQueryable().Order().Count(); | ||
| Assert.Equal(3, count); | ||
| } | ||
| [Fact] | ||
| public void Order2() | ||
| { | ||
| var count = (new int[] { 0, 1, 2 }).AsQueryable().Order(Comparer<int>.Default).Count(); | ||
| Assert.Equal(3, count); | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.