Esempio n. 1
0
            public void ShouldBeAbleToRemoveItem(int times)
            {
                var set = new AddressSet <int> {
                    0, 1, 2, 3
                };

                for (var j = 0; j < times; j++)
                {
                    for (var i = 0; i < set.Count; i++)
                    {
                        var real = set.ToList()[i];
                        real.Should().Be(i);
                    }
                }

                set.Remove(3);

                for (var j = 0; j < times; j++)
                {
                    set.Contains(3).Should().BeFalse();

                    for (var i = 0; i < set.Count; i++)
                    {
                        var real = set.ToList()[i];
                        real.Should().Be(i);
                    }
                }
            }
Esempio n. 2
0
            public void ShouldBeAbleToAccessNewlyAddedItem(int times)
            {
                var set = new AddressSet <int> {
                    0, 1, 2, 3
                };

                // we loop several turns on the full set
                for (var j = 0; j < times; j++)
                {
                    for (var i = 0; i < set.Count; i++)
                    {
                        var real = set.ToList()[i];
                        real.Should().Be(i);
                    }
                }

                // we add a new item into the set
                set.Add(4);

                // we loop again and everything is in set
                for (var j = 0; j < times; j++)
                {
                    // first we got the newly added out
                    set.Contains(4).Should().BeTrue();

                    for (var i = 0; i < set.Count; i++)
                    {
                        var real = set.ToList()[i];
                        real.Should().Be(i);
                    }
                }
            }