示例#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);
                    }
                }
            }
示例#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);
                    }
                }
            }
示例#3
0
            public void ShouldAddNew()
            {
                // ReSharper disable once UseObjectOrCollectionInitializer
                var set = new AddressSet <int>();

                set.Add(1);
                set.Count.Should().Be(1);
                set.ToList().Should().ContainInOrder(1);
            }
示例#4
0
            public void ShouldNotMoveIfNotExists()
            {
                var set = new AddressSet <int> {
                    0, 1
                };

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

                set.Remove(0);
                set.Remove(2);
                set.ToList().Should().ContainInOrder(1, 3);
            }