コード例 #1
0
        public void IsDisposedShouldBeTrue()
        {
            var stub = new DisposableObjectStub();

            stub.Dispose();

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

            stub.Dispose();

            Assert.That(stub.IsDisposingUnmanagedResourcesCalled, Is.True);
        }
コード例 #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));
        }
コード例 #4
0
        public void OnDisposingShouldBeCalled()
        {
            var stub = new DisposableObjectStub();

            stub.Dispose();

            Assert.That(stub.IsOnDisposingBeenCalled, Is.True);
        }
コード例 #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);
        }