-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Akka.Persistence.Query: made Offset IComparable to itself (#3950)
* close #3947 - made Offset IComparable to itself * forgot to mark second test as FACT * approved API changes
- Loading branch information
1 parent
caf13f6
commit 90a3db9
Showing
3 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/core/Akka.Persistence.Query.Tests/OffsetCompareSpecs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="OffsetCompareSpecs.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2019 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2019 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
//----------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Akka.Persistence.Query.Tests | ||
{ | ||
public class OffsetCompareSpecs | ||
{ | ||
[Theory] | ||
[InlineData(new[]{ 1L, 3L, 4L, 5L, 6L })] | ||
[InlineData(new[] { 6L, 2L, 1L, 5L, 3L })] | ||
public void Offsets_should_compare_correctly(long[] seqNos) | ||
{ | ||
var offsets = seqNos.Select(x => new Sequence(x)).Cast<Offset>(); | ||
var orderedSeqNos = seqNos.OrderBy(x => x).ToList(); | ||
var orderedOffset = new SortedSet<Offset>(offsets); | ||
|
||
var i = 0; | ||
foreach (var offset in orderedOffset.Cast<Sequence>()) | ||
{ | ||
offset.Value.Should().Be(orderedSeqNos[i]); | ||
i++; | ||
} | ||
} | ||
|
||
[Fact] | ||
public void Offsets_of_different_types_should_throw_on_compare() | ||
{ | ||
Offset seq = new Sequence(0L); | ||
|
||
Action compare1 = () => seq.CompareTo(NoOffset.Instance); | ||
Action compare2 = () => NoOffset.Instance.CompareTo(seq); | ||
|
||
compare1.ShouldThrow<InvalidOperationException>(); | ||
compare2.ShouldThrow<InvalidOperationException>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters