示例#1
0
            public void ShouldNotAddIfAlreadyExists()
            {
                // ReSharper disable once UseObjectOrCollectionInitializer
                var set = new AddressSet <int> {
                    0, 1, 2, 3
                };

                set.Add(0);
                set.Add(1);
                set.Add(2);
                set.Add(3);
                set.Count.Should().Be(4);
                set.Should().ContainInOrder(0, 1, 2, 3);
            }
示例#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 ShouldProvideSnapshotAfterUpdate()
            {
                // Given
                var set = new AddressSet <int> {
                    0, 1, 2
                };

                // When
                set.Remove(1);
                set.Add(42);
                var snaphost = set.Snaphost;

                // Then
                snaphost.Should().HaveCount(3);
                snaphost.Should().ContainInOrder(0, 2, 42);
            }