예제 #1
0
        public void AddingAndRemovingPeopleMaintainsCorrectCount()
        {
            ArraySet set = new ArraySet();

            var alice = new Person {
                Name = "Alice"
            };
            var bob = new Person {
                Name = "Bob"
            };
            var charlie = new Person {
                Name = "Charlie"
            };

            Assert.AreEqual(0, set.Count());
            set.Add(alice);
            Assert.AreEqual(1, set.Count());
            set.Add(bob);
            Assert.AreEqual(2, set.Count());
            set.Add(charlie);
            Assert.AreEqual(3, set.Count());

            set.Remove(bob);
            Assert.AreEqual(2, set.Count());
            set.Remove(charlie);
            Assert.AreEqual(1, set.Count());
            set.Remove(alice);
            Assert.AreEqual(0, set.Count());
        }
예제 #2
0
        public void CountIsCorrect_1()
        {
            ArraySet set = new ArraySet();

            set.Add(new Person {
                Name = "Alice"
            });

            Assert.AreEqual(1, set.Count());
        }
예제 #3
0
        public void AddingPersonMultipleTimesDoesNotChangeCount()
        {
            ArraySet set = new ArraySet();

            var alice = new Person {
                Name = "Alice"
            };

            set.Add(alice);
            set.Add(alice);

            Assert.AreEqual(1, set.Count());
        }
예제 #4
0
        public void CountIsCorrect_10K()
        {
            ArraySet set = new ArraySet();

            for (int i = 0; i < 10000; i++)
            {
                set.Add(new Person {
                    Name = $"Alice_{i}"
                });
            }

            Assert.AreEqual(10000, set.Count());
        }
예제 #5
0
        public void RemovingMultipleTimesDoesNotChangeCount()
        {
            ArraySet set = new ArraySet();

            var alice = new Person {
                Name = "Alice"
            };
            var bob = new Person {
                Name = "Bob"
            };
            var charlie = new Person {
                Name = "Charlie"
            };

            set.Add(alice);
            set.Add(bob);
            set.Add(charlie);
            Assert.AreEqual(3, set.Count());

            set.Remove(bob);
            set.Remove(bob);
            set.Remove(bob);
            Assert.AreEqual(2, set.Count());
        }
예제 #6
0
        public void AddingMultiplePeopleMultipleTimesDoesNotChangeCount()
        {
            ArraySet set = new ArraySet();

            var alice = new Person {
                Name = "Alice"
            };
            var bob = new Person {
                Name = "Bob"
            };

            set.Add(alice);
            set.Add(bob);
            set.Add(alice);
            set.Add(bob);

            Assert.AreEqual(2, set.Count());
        }
예제 #7
0
        public void CountIsCorrect_5()
        {
            ArraySet set = new ArraySet();

            set.Add(new Person {
                Name = "Alice"
            });
            set.Add(new Person {
                Name = "Bob"
            });
            set.Add(new Person {
                Name = "Charlie"
            });
            set.Add(new Person {
                Name = "Dolan"
            });
            set.Add(new Person {
                Name = "Gooby"
            });

            Assert.AreEqual(5, set.Count());
        }
예제 #8
0
        public void CountIsCorrect_0()
        {
            ArraySet set = new ArraySet();

            Assert.AreEqual(0, set.Count());
        }