Skip to content

Commit

Permalink
SortedSets: de-LINQ
Browse files Browse the repository at this point in the history
  • Loading branch information
NickCraver committed Apr 16, 2022
1 parent 2991bd8 commit 0779e45
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions tests/StackExchange.Redis.Tests/SortedSets.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
Expand Down Expand Up @@ -1035,17 +1034,18 @@ 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);
Assert.Equal(key, bottom2.Key);
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]
Expand All @@ -1066,17 +1066,18 @@ 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);
Assert.Equal(key, bottom2.Key);
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]
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 0779e45

Please sign in to comment.