コード例 #1
0
ファイル: UriExtensionsTests.cs プロジェクト: aspnet/WebHooks
        public void IsHttp_DetectsHttpUris(string input, bool expected)
        {
            // Arrange
            Uri address = new Uri(input, UriKind.RelativeOrAbsolute);

            // Act
            bool actual = address.IsHttp();

            // Assert
            Assert.Equal(expected, actual);
        }
コード例 #2
0
        public void IsHttp_HandlesNull()
        {
            // Arrange
            Uri address = null;

            // Act
            bool actual = address.IsHttp();

            // Assert
            Assert.False(actual);
        }
コード例 #3
0
        public void IsHttp_DetectsHttpUris(string input, bool expected)
        {
            // Arrange
            Uri address = new Uri(input, UriKind.RelativeOrAbsolute);

            // Act
            bool actual = address.IsHttp();

            // Assert
            Assert.Equal(expected, actual);
        }
コード例 #4
0
 private void InitializeValues(string method, Uri requestUri)
 {
     if (method.IsNullOrEmpty()) {
         throw new ArgumentNullException("method");
     }
     if (requestUri != null && requestUri.IsAbsoluteUri && !requestUri.IsHttp()) {
         throw new ArgumentException("SR.net_http_client_http_baseaddress_required", "requestUri");
     }
     this.Headers = new HttpRequestHeaders();
     this.Method = method;
     this.RequestUri = requestUri;
     this.Version = new Version(1, 1);
 }
コード例 #5
0
ファイル: WebHookManager.cs プロジェクト: aspnet/WebHooks
 /// <summary>
 /// Verifies that the <paramref name="webHookUri"/> has either an 'http' or 'https' scheme.
 /// </summary>
 /// <param name="webHookUri">The URI to verify.</param>
 protected virtual void VerifyUri(Uri webHookUri)
 {
     // Check that WebHook URI scheme is either '<c>http</c>' or '<c>https</c>'.
     if (!(webHookUri.IsHttp() || webHookUri.IsHttps()))
     {
         string msg = string.Format(CultureInfo.CurrentCulture, CustomResources.Manager_NoHttpUri, webHookUri);
         _logger.Error(msg);
         throw new InvalidOperationException(msg);
     }
 }