示例#1
0
        public void ExitListLock()
        {
            var enumerator = new ReadLockEnumerator <int>(_list, _lock);

            enumerator.Dispose();
            _lock.IsReadLockHeld.Should().BeFalse();
        }
示例#2
0
        public void ExitDictionaryLock()
        {
            var enumerator = new ReadLockEnumerator <int, int>(_dictionary.Values, _lock);

            enumerator.Dispose();
            _lock.IsReadLockHeld.Should().BeFalse();
        }
示例#3
0
        public void EnumerateList()
        {
            var enumerator = new ReadLockEnumerator <int>(_list, _lock);
            var counter    = 0;

            while (enumerator.MoveNext())
            {
                _list[counter++].Should().Be(enumerator.Current);
            }

            counter.Should().Be(_list.Count);
            enumerator.Dispose();
        }
示例#4
0
        public void EnumerateDictionary()
        {
            var exists = new HashSet <int>();

            var enumerator = new ReadLockEnumerator <int, int>(_dictionary.Values, _lock);

            while (enumerator.MoveNext())
            {
                exists.Add(enumerator.Current).Should().BeTrue();
            }

            exists.Count.Should().Be(_dictionary.Count);
            enumerator.Dispose();
        }