Example #1
0
        public void IsDisposedShouldBeTrue()
        {
            var stub = new DisposableObjectStub();

            stub.Dispose();

            Assert.That(stub.IsDisposed, Is.True);
        }
Example #2
0
        public void DisposingUnmanagedResourcesShouldBeCalled()
        {
            var stub = new DisposableObjectStub();

            stub.Dispose();

            Assert.That(stub.IsDisposingUnmanagedResourcesCalled, Is.True);
        }
Example #3
0
        public void DisposingShouldBeFired()
        {
            var testHelper = new GenericEventListener<EventArgs>();

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

            Assert.That(testHelper.HasBeenRaised, Is.True);
            Assert.That(testHelper.RaiseCounter, Is.EqualTo(1));
        }
Example #4
0
        public void OnDisposingShouldBeCalled()
        {
            var stub = new DisposableObjectStub();

            stub.Dispose();

            Assert.That(stub.IsOnDisposingBeenCalled, Is.True);
        }
Example #5
0
        public void OnlyDisposingUnmanagedResourcesShouldBeCalled()
        {
            var stub = new DisposableObjectStub();

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

            Assert.That(stub.IsDisposingUnmanagedResourcesCalled, Is.True);
            Assert.That(stub.IsDisposingManagedResourcesCalled, Is.False);
        }