public void CreateDisposeRelease_ThrowsObjectDisposedException()
        {
            var safeHandle = new FakeSafeWinHttpHandle(true);

            safeHandle.Dispose();
            Assert.Throws <ObjectDisposedException>(() => safeHandle.DangerousRelease());
        }
Esempio n. 2
0
        public void Dispose()
        {
            TestControl.ResponseDelayCompletedEvent.WaitOne();

            FakeSafeWinHttpHandle.ForceGarbageCollection();
            Assert.Equal(0, FakeSafeWinHttpHandle.HandlesOpen);
        }
        public void CreateDisposeAddRef_ThrowsObjectDisposedException()
        {
            var safeHandle = new FakeSafeWinHttpHandle(true);

            safeHandle.Dispose();
            Assert.Throws <ObjectDisposedException>(() =>
                                                    { bool ignore = false; safeHandle.DangerousAddRef(ref ignore); });
        }
        public void CreateDispose_HandleIsClosed()
        {
            var safeHandle = new FakeSafeWinHttpHandle(true);

            safeHandle.Dispose();

            Assert.True(safeHandle.IsClosed, "closed");
        }
        internal Stream MakeResponseStream()
        {
            var sessionHandle = new FakeSafeWinHttpHandle(true);
            var connectHandle = new FakeSafeWinHttpHandle(true);
            var requestHandle = new FakeSafeWinHttpHandle(true);

            return(new WinHttpResponseStream(sessionHandle, connectHandle, requestHandle));
        }
Esempio n. 6
0
        internal Stream MakeResponseStream()
        {
            var state  = new WinHttpRequestState();
            var handle = new FakeSafeWinHttpHandle(true);

            handle.Callback     = WinHttpRequestCallback.StaticCallbackDelegate;
            handle.Context      = state.ToIntPtr();
            state.RequestHandle = handle;

            return(new WinHttpResponseStream(handle, state));
        }
        public void SetParentHandle_CreateParentCreateChildDisposeChildDisposeParent_HandlesClosed()
        {
            var parentHandle = new FakeSafeWinHttpHandle(true);
            var childHandle  = new FakeSafeWinHttpHandle(true);

            childHandle.SetParentHandle(parentHandle);
            childHandle.Dispose();
            parentHandle.Dispose();

            Assert.True(parentHandle.IsClosed, "closed");
            Assert.True(childHandle.IsClosed, "closed");
        }
 public void CreateAddRefDisposeRelease_HandleIsClosed()
 {
     var safeHandle = new FakeSafeWinHttpHandle(true);
     bool success = false;
     safeHandle.DangerousAddRef(ref success);
     Assert.True(success, "DangerousAddRef");
     safeHandle.Dispose();
     safeHandle.DangerousRelease();
     
     Assert.True(safeHandle.IsClosed, "closed");
     Assert.Equal(0, FakeSafeWinHttpHandle.HandlesOpen);
 }
Esempio n. 9
0
        public void CreateAddRefReleaseDispose_HandleIsClosed()
        {
            var  safeHandle = new FakeSafeWinHttpHandle(true);
            bool success    = false;

            safeHandle.DangerousAddRef(ref success);
            Assert.True(success, "DangerousAddRef");
            safeHandle.DangerousRelease();
            safeHandle.Dispose();

            Assert.True(safeHandle.IsClosed, "closed");
        }
Esempio n. 10
0
        public void SetParentHandle_CreateParentCreateChildDisposeParent_ParentNotClosed()
        {
            var parentHandle = new FakeSafeWinHttpHandle(true);
            var childHandle  = new FakeSafeWinHttpHandle(true);

            childHandle.SetParentHandle(parentHandle);
            parentHandle.Dispose();

            Assert.False(parentHandle.IsClosed, "closed");

            // Clean up safeHandles to keep outstanding handles at zero.
            childHandle.Dispose();
        }
Esempio n. 11
0
        internal Stream MakeRequestStream()
        {
            var state = new WinHttpRequestState();

            state.Pin();
            var handle = new FakeSafeWinHttpHandle(true);

            handle.Callback     = WinHttpRequestCallback.StaticCallbackDelegate;
            handle.Context      = state.ToIntPtr();
            state.RequestHandle = handle;

            return(new WinHttpRequestStream(state, WinHttpChunkMode.None));
        }
Esempio n. 12
0
        public void CreateAddRefRelease_HandleIsNotClosed()
        {
            var  safeHandle = new FakeSafeWinHttpHandle(true);
            bool success    = false;

            safeHandle.DangerousAddRef(ref success);
            Assert.True(success, "DangerousAddRef");
            safeHandle.DangerousRelease();

            Assert.False(safeHandle.IsClosed, "closed");

            // Clean up safeHandle to keep outstanding handles at zero.
            safeHandle.Dispose();
        }
Esempio n. 13
0
 public void CreateAddRefRelease_HandleIsNotClosed()
 {
     var safeHandle = new FakeSafeWinHttpHandle(true);
     bool success = false;
     safeHandle.DangerousAddRef(ref success);
     Assert.True(success, "DangerousAddRef");
     safeHandle.DangerousRelease();
     
     Assert.False(safeHandle.IsClosed, "closed");
     Assert.Equal(1, FakeSafeWinHttpHandle.HandlesOpen);
     
     // Clean up safeHandle to keep outstanding handles at zero.
     safeHandle.Dispose();
 }
Esempio n. 14
0
        public void SendAsync_MultipleCallsWithoutDispose_NoHandleLeaks()
        {
            WinHttpHandler      handler;
            HttpResponseMessage response;

            for (int i = 0; i < 50; i++)
            {
                handler  = new WinHttpHandler();
                response = SendRequestHelper(handler, () => { });
            }

            handler  = null;
            response = null;
            FakeSafeWinHttpHandle.ForceGarbageCollection();

            Assert.Equal(0, FakeSafeWinHttpHandle.HandlesOpen);
        }
Esempio n. 15
0
        internal Stream MakeResponseStream()
        {
            var requestHandle = new FakeSafeWinHttpHandle(true);

            return new WinHttpResponseStream(requestHandle);
        }
Esempio n. 16
0
        internal Stream MakeResponseStream()
        {
            var requestHandle = new FakeSafeWinHttpHandle(true);

            return(new WinHttpResponseStream(requestHandle));
        }
Esempio n. 17
0
 public void SetParentHandle_CreateParentCreateChildDisposeChildDisposeParent_HandlesClosed()
 {
     var parentHandle = new FakeSafeWinHttpHandle(true);
     var childHandle = new FakeSafeWinHttpHandle(true);
     childHandle.SetParentHandle(parentHandle);
     childHandle.Dispose();
     parentHandle.Dispose();
     
     Assert.True(parentHandle.IsClosed, "closed");
     Assert.True(childHandle.IsClosed, "closed");
 }
Esempio n. 18
0
 public void SetParentHandle_CreateParentCreateChildDisposeParent_ParentNotClosed()
 {
     var parentHandle = new FakeSafeWinHttpHandle(true);
     var childHandle = new FakeSafeWinHttpHandle(true);
     childHandle.SetParentHandle(parentHandle);
     parentHandle.Dispose();
     
     Assert.False(parentHandle.IsClosed, "closed");
     Assert.Equal(2, FakeSafeWinHttpHandle.HandlesOpen);
     
     // Clean up safeHandles to keep outstanding handles at zero.
     childHandle.Dispose();
 }
Esempio n. 19
0
 public void CreateDisposeRelease_ThrowsObjectDisposedException()
 {
     var safeHandle = new FakeSafeWinHttpHandle(true);
     safeHandle.Dispose();
     Assert.Throws<ObjectDisposedException>(() => safeHandle.DangerousRelease());
 }
Esempio n. 20
0
 public void CreateDisposeAddRef_ThrowsObjectDisposedException()
 {
     var safeHandle = new FakeSafeWinHttpHandle(true);
     safeHandle.Dispose();
     Assert.Throws<ObjectDisposedException>(() => 
         { bool ignore = false; safeHandle.DangerousAddRef(ref ignore); });
 }
Esempio n. 21
0
 public void CreateDisposeDispose_HandleIsClosedAndSecondDisposeIsNoop()
 {
     var safeHandle = new FakeSafeWinHttpHandle(true);
     safeHandle.Dispose();
     safeHandle.Dispose();
     Assert.True(safeHandle.IsClosed, "closed");
 }
Esempio n. 22
0
 public void Dispose()
 {
     // This runs after every test and makes sure that we run any finalizers to free all eligible handles.
     FakeSafeWinHttpHandle.ForceGarbageCollection();
     Assert.Equal(0, FakeSafeWinHttpHandle.HandlesOpen);
 }
        internal Stream MakeRequestStream()
        {
            SafeWinHttpHandle requestHandle = new FakeSafeWinHttpHandle(true);

            return(new WinHttpRequestStream(requestHandle, false));
        }
Esempio n. 24
0
        internal Stream MakeRequestStream()
        {
            SafeWinHttpHandle requestHandle = new FakeSafeWinHttpHandle(true);

            return new WinHttpRequestStream(requestHandle, false);
        }
        internal Stream MakeRequestStream()
        {
            var state = new WinHttpRequestState();
            var handle = new FakeSafeWinHttpHandle(true);
            handle.Callback = WinHttpRequestCallback.StaticCallbackDelegate;
            handle.Context = state.ToIntPtr();
            state.RequestHandle = handle;

            return new WinHttpRequestStream(state, false);
        }
Esempio n. 26
0
        internal Stream MakeResponseStream()
        {
            var sessionHandle = new FakeSafeWinHttpHandle(true);
            var connectHandle = new FakeSafeWinHttpHandle(true);
            var requestHandle = new FakeSafeWinHttpHandle(true);

            return new WinHttpResponseStream(sessionHandle, connectHandle, requestHandle);
        }