Ejemplo n.º 1
0
        public void CallProtectedMethodDisposingUnmanagedResourcesWhenUserCodeCallsDispose()
        {
            DisposableObjectStub stub = new DisposableObjectStub();

            stub.Dispose();

            Assert.That(stub.IsDisposingUnmanagedResourcesCalled, Is.True);
        }
Ejemplo n.º 2
0
        public void CallProtectedMethodOnDisposingWhenUserCodeCallsDispose()
        {
            DisposableObjectStub stub = new DisposableObjectStub();

            stub.Dispose();

            Assert.That(stub.IsOnDisposingBeenCalled, Is.True);
        }
Ejemplo n.º 3
0
        public void OnlyCallProtectedMethodDisposingUnmanagedResourcesWhenFinaliserCallsDispose()
        {
            DisposableObjectStub stub = new DisposableObjectStub();

            stub.InvokePrivateMethod("Dispose", new[] { typeof(bool) }, false);

            Assert.That(stub.IsDisposingUnmanagedResourcesCalled, Is.True);
            Assert.That(stub.IsDisposingManagedResourcesCalled, Is.False);
        }
Ejemplo n.º 4
0
        public void RaiseDisposedWhenDisposedWhenUserCodeCallsDispose()
        {
            GenericEventListener<EventArgs> testHelper = new GenericEventListener<EventArgs>();

            using (DisposableObjectStub stub = new DisposableObjectStub())
            {
                stub.Disposed += testHelper.Listen;
            }

            Assert.That(testHelper.HasBeenRaised, Is.True);
            Assert.That(testHelper.RaiseCounter, Is.EqualTo(1));
        }
Ejemplo n.º 5
0
        public void ReturnTrueWhenHittingIsDisposedGivenTheObjectIsDisposed()
        {
            DisposableObjectStub stub = new DisposableObjectStub();

            stub.Dispose();

            Assert.That(stub.IsDisposed, Is.True);
        }