Ejemplo n.º 1
0
            public void DoesNotThrowAfterDisposingEnumerator()
            {
                var list       = new DeletableObjectList <TestDeletable>();
                var enumerator = list.GetEnumerator();

                enumerator.Dispose();

                CallMethod(list);
            }
Ejemplo n.º 2
0
            public void ThrowsIfEnumerating()
            {
                var list = new DeletableObjectList <TestDeletable>();

                list.GetEnumerator();

                Action callingWhileEnumerating = () => CallMethod(list);

                Assert.Throws <InvalidOperationException>(callingWhileEnumerating);
            }
Ejemplo n.º 3
0
            public void DoesNotThrowIfAllEnumeratorsAreDisposed()
            {
                var list        = new DeletableObjectList <TestDeletable>();
                var enumerators = Enumerable.Range(0, 20).Select(i => list.GetEnumerator()).ToList();

                foreach (var enumerator in enumerators)
                {
                    enumerator.Dispose();
                }

                CallMethod(list);
            }
Ejemplo n.º 4
0
            public void ThrowsIfAtLeastOneEnumeratorIsNotDisposed()
            {
                var list                = new DeletableObjectList <TestDeletable>();
                var enumerators         = Enumerable.Range(0, 20).Select(i => list.GetEnumerator()).ToList();
                var arbitraryEnumerator = enumerators[7];

                foreach (var enumerator in enumerators.Except(new [] { arbitraryEnumerator }))
                {
                    enumerator.Dispose();
                }

                Action callingWhileEnumerating = () => CallMethod(list);

                Assert.Throws <InvalidOperationException>(callingWhileEnumerating);
            }