public void SendAsync_NullRequest_ThrowsArgumentNullException()
        {
            RemoteInvoke(async() =>
            {
                var diagnosticListenerObserver = new FakeDiagnosticListenerObserver(null);
                using (DiagnosticListener.AllListeners.Subscribe(diagnosticListenerObserver))
                {
                    diagnosticListenerObserver.Enable();

                    using (MyHandler handler = new MyHandler())
                    {
                        // Getting the Task first from the .SendAsync() call also tests
                        // that the exception comes from the async Task path.
                        Task t = handler.SendAsync(null);
                        if (PlatformDetection.IsUap)
                        {
                            await Assert.ThrowsAsync <HttpRequestException>(() => t);
                        }
                        else
                        {
                            await Assert.ThrowsAsync <ArgumentNullException>(() => t);
                        }
                    }
                }

                diagnosticListenerObserver.Disable();
                return(SuccessExitCode);
            }).Dispose();
        }
Beispiel #2
0
        public void SendAsync_NullRequest_ThrowsArgumentNullException()
        {
            RemoteInvoke(() =>
            {
                var diagnosticListenerObserver = new FakeDiagnosticListenerObserver(null);
                using (DiagnosticListener.AllListeners.Subscribe(diagnosticListenerObserver))
                {
                    diagnosticListenerObserver.Enable();

                    using (MyHandler handler = new MyHandler())
                    {
                        Assert.ThrowsAsync <ArgumentNullException>(() => handler.SendAsync(null)).Wait();
                    }
                }

                diagnosticListenerObserver.Disable();
                return(SuccessExitCode);
            }).Dispose();
        }