Пример #1
0
        public void ExitListLock()
        {
            var enumerator = new ReadLockWhereEnumerator <int, int>(_list, _stub, 0, _lock);

            enumerator.Dispose();
            _lock.IsReadLockHeld.Should().BeFalse();
        }
Пример #2
0
        public void ExitDictionaryLock()
        {
            var enumerator = new ReadLockWhereEnumerator <int, int, int>(_dictionary.Values, _stub, 0, _lock);

            enumerator.Dispose();
            _lock.IsReadLockHeld.Should().BeFalse();
        }
Пример #3
0
        public void EnumerateListAsEnumerator()
        {
            var exists = new HashSet <int>();

            var lockEnumerator = new ReadLockWhereEnumerator <int, int>(_list, _stub, 0, _lock);
            var enumerator     = ((IEnumerable)lockEnumerator).GetEnumerator();

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

            exists.Count.Should().Be(_list.Count);
        }
Пример #4
0
        public void EnumerateList()
        {
            var exists = new HashSet <int>();

            var enumerator = new ReadLockWhereEnumerator <int, int>(_list, _stub, 0, _lock);

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

            exists.Count.Should().Be(_list.Count);
            enumerator.Dispose();
        }
Пример #5
0
        public void FilterListValues()
        {
            var exists = new HashSet <int>();

            var greatestValue = _list.Max();
            var enumerator    = new ReadLockWhereEnumerator <int, int>(_list, (v, arg) => v >= arg, greatestValue, _lock);

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

            exists.Count.Should().Be(1);
            exists.Should().ContainSingle(v => v == greatestValue);
            enumerator.Dispose();
        }
Пример #6
0
        public void EnterListLock()
        {
            var _ = new ReadLockWhereEnumerator <int, int>(_list, _stub, 0, _lock);

            _lock.IsReadLockHeld.Should().BeTrue();
        }
Пример #7
0
        public void EnterDictionaryLock()
        {
            var _ = new ReadLockWhereEnumerator <int, int, int>(_dictionary.Values, _stub, 0, _lock);

            _lock.IsReadLockHeld.Should().BeTrue();
        }