コード例 #1
0
        public void CountedSetSupportsGenericIteration()
        {
            var set = new CountedSet <string>(new[] { "foo", "foo", "foo", "bar", "bar" });

            Assert.DoesNotThrow(() =>
            {
                IEnumerator <string> enumerator = set.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    //ignore empty block
                }
            });
        }
コード例 #2
0
        public void CountSetSupportsGenericIterationForExpectedNumberOfElements()
        {
            const int expected = 2;
            int       count    = 0;

            var set = new CountedSet <string>(new[] { "foo", "foo", "foo", "bar", "bar" });

            IEnumerator <string> enumerator = set.GetEnumerator();

            while (enumerator.MoveNext())
            {
                count++;
            }
            Assert.AreEqual(expected, count);
        }