예제 #1
0
        public void Dispose_CalledTwice_CallsSyncHooksOnlyOnce()
        {
            // Arrange
            var resource = new DisposableResourceSpy();

            // Act
            resource.Dispose();
            resource.Dispose();

            // Assert
            Assert.AreEqual(1, resource.ReleaseManagedResourcesCallCount);
            Assert.AreEqual(1, resource.ReleaseNativeResourcesCallCount);
            Assert.AreEqual(0, resource.ReleaseManagedResourcesAsyncCallCount);
        }
예제 #2
0
        public void Dispose_ByDefault_Disposes()
        {
            // Arrange
            var resource = new DisposableResourceSpy();

            // Act
            resource.Dispose();

            // Assert
            Assert.IsTrue(resource.IsDisposed);
        }
예제 #3
0
        public void Dispose_ByDefault_CallsAllSyncHooks()
        {
            // Arrange
            var resource = new DisposableResourceSpy();

            // Act
            resource.Dispose();

            // Assert
            Assert.AreEqual(1, resource.ReleaseManagedResourcesCallCount);
            Assert.AreEqual(1, resource.ReleaseNativeResourcesCallCount);
            Assert.AreEqual(0, resource.ReleaseManagedResourcesAsyncCallCount);
        }