public void ShouldHandleZeroLength() { var roundRobinIndex = new RoundRobinArrayIndex(); int index = roundRobinIndex.Next(0); index.Should().Be(-1); }
public void ShouldHandleOverflow() { int arrayLength = 10; RoundRobinArrayIndex roundRobinIndex = new RoundRobinArrayIndex(Int32.MaxValue - 2); roundRobinIndex.Next(arrayLength).Should().Be((Int32.MaxValue - 1) % arrayLength); roundRobinIndex.Next(arrayLength).Should().Be(Int32.MaxValue % arrayLength); roundRobinIndex.Next(arrayLength).Should().Be(0); roundRobinIndex.Next(arrayLength).Should().Be(1); roundRobinIndex.Next(arrayLength).Should().Be(2); }
public void ShouldReturnIndexesInRoundRobinOrder() { RoundRobinArrayIndex roundRobinIndex = new RoundRobinArrayIndex(); for (int i = 0; i < 10; i++) { int index = roundRobinIndex.Next(10); index.Should().Be(i); } for (int i = 0; i < 5; i++) { int index = roundRobinIndex.Next(5); index.Should().Be(i); } }