public void ShouldRemove()
            {
                var set = new ConcurrentRoundRobinSet <int> {
                    0, 1, 2, 3
                };

                set.Remove(0);
                set.Remove(2);
                set.ToList().Should().ContainInOrder(1, 3);
            }
            public void ShouldBeAbleToRemoveItem(int times)
            {
                var set = new ConcurrentRoundRobinSet <int> {
                    0, 1, 2, 3
                };

                for (var j = 0; j < times; j++)
                {
                    for (var i = 0; i < set.Count; i++)
                    {
                        int real;
                        set.TryNext(out real).Should().BeTrue();
                        real.Should().Be(i);
                    }
                }

                set.Remove(3);

                for (var j = 0; j < times; j++)
                {
                    for (var i = 0; i < set.Count; i++)
                    {
                        int real;
                        set.TryNext(out real).Should().BeTrue();
                        real.Should().Be(i);
                    }
                }
            }
            public void ShouldNotMoveIfNotExists()
            {
                var set = new ConcurrentRoundRobinSet <int> {
                    0, 1
                };

                set.Remove(3);
                set.Count.Should().Be(2);
                set.ToList().Should().ContainInOrder(0, 1);
            }
示例#4
0
            public void ShouldBeAbleToRemoveItem()
            {
                var set = new ConcurrentRoundRobinSet <int> {
                    0, 1, 2, 3
                };

                for (var i = 0; i < 3 * set.Count; i++)
                {
                    int real;
                    set.TryNext(out real).Should().BeTrue();
                    var expect = i % set.Count;
                    real.Should().Be(expect);
                }

                set.Remove(3);

                for (var i = 0; i < 3 * set.Count; i++)
                {
                    int real;
                    set.TryNext(out real).Should().BeTrue();
                    var expect = i % set.Count;
                    real.Should().Be(expect);
                }
            }