예제 #1
0
        public void ScopedInstanceDoesNotThrowOnNonIDisposable()
        {
            // Arrange
            var scopedInstance = new ScopedInstance <object>()
            {
                Value = new object(),
            };

            // Act
            scopedInstance.Dispose();
        }
예제 #2
0
        public void ScopedInstanceDoesNotThrowOnNull()
        {
            // Arrange
            var scopedInstance = new ScopedInstance <Disposable>()
            {
                Value = null, // just making it explicit that there is not value set yet.
            };

            // Act
            scopedInstance.Dispose();

            // Assert
            Assert.Null(scopedInstance.Value);
        }
예제 #3
0
        public void ScopedInstanceDisposesIDisposables()
        {
            var disposable = new Disposable();

            // Arrange
            var scopedInstance = new ScopedInstance <Disposable>
            {
                Value = disposable,
            };

            // Act
            scopedInstance.Dispose();

            // Assert
            Assert.True(disposable.IsDisposed);
        }