From 0779e45cf01f64d6f13111c178fa703a55b4db49 Mon Sep 17 00:00:00 2001 From: Nick Craver Date: Fri, 15 Apr 2022 22:52:43 -0400 Subject: [PATCH] SortedSets: de-LINQ --- tests/StackExchange.Redis.Tests/SortedSets.cs | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/tests/StackExchange.Redis.Tests/SortedSets.cs b/tests/StackExchange.Redis.Tests/SortedSets.cs index fed484d3f..33ef9a4ff 100644 --- a/tests/StackExchange.Redis.Tests/SortedSets.cs +++ b/tests/StackExchange.Redis.Tests/SortedSets.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; @@ -1035,8 +1034,9 @@ public void SortedSetMultiPopSingleKey() var highest = db.SortedSetPop(new RedisKey[] { key }, 1, order: Order.Descending); Assert.False(highest.IsNull); Assert.Equal(key, highest.Key); - Assert.Equal("rays", highest.Entries.Single().Element); - Assert.Equal(100, highest.Entries.Single().Score); + var entry = Assert.Single(highest.Entries); + Assert.Equal("rays", entry.Element); + Assert.Equal(100, entry.Score); var bottom2 = db.SortedSetPop(new RedisKey[] { key }, 2); Assert.False(bottom2.IsNull); @@ -1044,8 +1044,8 @@ public void SortedSetMultiPopSingleKey() Assert.Equal(2, bottom2.Entries.Length); Assert.Equal("orioles", bottom2.Entries[0].Element); Assert.Equal(52, bottom2.Entries[0].Score); - Assert.Equal("blue jays", bottom2.Entries.Last().Element); - Assert.Equal(91, bottom2.Entries.Last().Score); + Assert.Equal("blue jays", bottom2.Entries[1].Element); + Assert.Equal(91, bottom2.Entries[1].Score); } [Fact] @@ -1066,8 +1066,9 @@ public void SortedSetMultiPopMultiKey() var highest = db.SortedSetPop(new RedisKey[] { "not a real key", key, "yet another not a real key" }, 1, order: Order.Descending); Assert.False(highest.IsNull); Assert.Equal(key, highest.Key); - Assert.Equal("rays", highest.Entries.Single().Element); - Assert.Equal(100, highest.Entries.Single().Score); + var entry = Assert.Single(highest.Entries); + Assert.Equal("rays", entry.Element); + Assert.Equal(100, entry.Score); var bottom2 = db.SortedSetPop(new RedisKey[] { "not a real key", key, "yet another not a real key" }, 2); Assert.False(bottom2.IsNull); @@ -1075,8 +1076,8 @@ public void SortedSetMultiPopMultiKey() Assert.Equal(2, bottom2.Entries.Length); Assert.Equal("orioles", bottom2.Entries[0].Element); Assert.Equal(52, bottom2.Entries[0].Score); - Assert.Equal("blue jays", bottom2.Entries.Last().Element); - Assert.Equal(91, bottom2.Entries.Last().Score); + Assert.Equal("blue jays", bottom2.Entries[1].Element); + Assert.Equal(91, bottom2.Entries[1].Score); } [Fact] @@ -1122,17 +1123,18 @@ public async Task SortedSetMultiPopAsync() new RedisKey[] { "not a real key", key, "yet another not a real key" }, 1, order: Order.Descending); Assert.False(highest.IsNull); Assert.Equal(key, highest.Key); - Assert.Equal("rays", highest.Entries.Single().Element); - Assert.Equal(100, highest.Entries.Single().Score); + var entry = Assert.Single(highest.Entries); + Assert.Equal("rays", entry.Element); + Assert.Equal(100, entry.Score); var bottom2 = await db.SortedSetPopAsync(new RedisKey[] { "not a real key", key, "yet another not a real key" }, 2); Assert.False(bottom2.IsNull); Assert.Equal(key, bottom2.Key); Assert.Equal(2, bottom2.Entries.Length); - Assert.Equal("orioles", bottom2.Entries.First().Element); - Assert.Equal(52, bottom2.Entries.First().Score); - Assert.Equal("blue jays", bottom2.Entries.Last().Element); - Assert.Equal(91, bottom2.Entries.Last().Score); + Assert.Equal("orioles", bottom2.Entries[0].Element); + Assert.Equal(52, bottom2.Entries[0].Score); + Assert.Equal("blue jays", bottom2.Entries[1].Element); + Assert.Equal(91, bottom2.Entries[1].Score); } [Fact]