Example #1
0
        public void Check_Exception()
        {
            DisposableFoo foo;

            using (foo = new DisposableFoo())
            {
                foo.Should().NotBeNull();
                foo.IsDisposed.Should().BeFalse();
                foo.Check();
            }

            foo.Should().NotBeNull();
            foo.IsDisposed.Should().BeTrue();

            Action act = () => foo.Check();

            act.Should().Throw <ObjectDisposedException>();
        }
Example #2
0
        public void Dispose_Test()
        {
            DisposableFoo foo;

            using (foo = new DisposableFoo())
            {
                foo.Should().NotBeNull();
                foo.IsDisposed.Should().BeFalse();
                foo.Check();
            }

            foo.Should().NotBeNull();
            foo.IsDisposed.Should().BeTrue();
        }
Example #3
0
        public void Dispose_Finalizer_Test()
        {
            var foo = new DisposableFoo();

            foo.Should().NotBeNull();
            foo.IsDisposed.Should().BeFalse();
            foo.Check();

            // ReSharper disable once RedundantAssignment
#pragma warning disable IDE0059 // Value assigned to symbol is never used
            foo = null;
            GC.WaitForPendingFinalizers();
#pragma warning restore IDE0059 // Value assigned to symbol is never used
        }