Esempio n. 1
0
        public void Read_ExceptionDuringEnumeration_LockReleased()
        {
            var array = new int[100];

            for (int i = 0; i < 100; i++)
            {
                array[i] = i;
            }

            var col = new RangeObservableCollection <int>(array);

            try
            {
                int x = 0;
                col.ForEach(c =>
                {
                    if (x++ > 50)
                    {
                        throw new Exception();
                    }
                });
            }
            catch (Exception)
            {
                _testOutputHelper.WriteLine("Exception was fired");
            }

            col.Add(3);

            col.Count.Should().Be(101);
        }
        public void Read_ExceptionDuringEnumeration_LockReleased()
        {
            var array = new int[100];

            for (int i = 0; i < 100; i++)
            {
                array[i] = i;
            }
            var col = new RangeObservableCollection <int>(array);

            try
            {
                int x = 0;
                col.ForEach(c =>
                {
                    if (x++ > 50)
                    {
                        throw new Exception();
                    }
                });
            }
            catch (Exception)
            {
                Console.WriteLine("Exception was fired");
            }

            col.Add(3);

            Assert.That(col.Count, Is.EqualTo(101));
        }