Пример #1
0
        public void Dispose_CanBeCalledMultipleTimes()
        {
            // Arrange
            var op = new AsyncResult(AsyncOperationStatus.Canceled);

            // Act/Assert
            op.Dispose();
            op.Dispose();
        }
Пример #2
0
        public void Dispose_ThrowsIfOperationIsNotCompleted()
        {
            // Arrange
            var op = new AsyncResult();

            // Act/Assert
            Assert.Throws <InvalidOperationException>(() => op.Dispose());
        }
Пример #3
0
        public void AsyncWaitHandle_ThrowsIfDisposed()
        {
            // Arrange
            var op = new AsyncResult(AsyncOperationStatus.Canceled);

            op.Dispose();

            // Act/Assert
            Assert.Throws <ObjectDisposedException>(() => op.AsyncWaitHandle);
        }
Пример #4
0
        public void Cancel_CanBeCalledWhenDisposed()
        {
            // Arrange
            var op = new AsyncResult(AsyncOperationStatus.RanToCompletion);

            op.Dispose();

            // Act/Assert
            op.Cancel();
        }
Пример #5
0
        public void MoveNext_CanBeCalledWhenDisposed()
        {
            // Arrange
            var op = new AsyncResult(AsyncOperationStatus.RanToCompletion);

            op.Dispose();

            // Act
            var result = (op as IEnumerator).MoveNext();

            // Assert
            Assert.False(result);
        }