Ejemplo n.º 1
0
        public void ScopedInstanceDoesNotThrowOnNonIDisposable()
        {
            // Arrange
            var scopedInstance = new ScopedInstance <object>()
            {
                Value = new object(),
            };

            // Act
            scopedInstance.Dispose();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }