Inheritance: RequestBuilderBase
コード例 #1
0
        public void GetTokenByCodeRequest_WithTokenNull_ThrowsArgumentNullException()
        {
            var requestBuilder = new OAuth2RequestBuilder();
            var exception =
                Record.Exception(() => requestBuilder.GetTokenByCodeRequest("url", null, "clientId", "clientSecret"));
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);

            var argNullException = (ArgumentNullException) exception;
            Assert.Equal(argNullException.ParamName, "code");
        }
コード例 #2
0
        public void GetTokenByCodeRequest_WithClientSecretNull_ThrowsArgumentNullException()
        {
            var requestBuilder = new OAuth2RequestBuilder();

            var exception =
                Record.Exception(
                    () =>
                        requestBuilder.GetTokenByCodeRequest("https://api.imgur.com/oauth2/token", "123code", "clientId",
                            null));
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);

            var argNullException = (ArgumentNullException) exception;
            Assert.Equal(argNullException.ParamName, "clientSecret");
        }
コード例 #3
0
        public async Task GetTokenByCodeRequest_WithCodeEqual()
        {
            var requestBuilder = new OAuth2RequestBuilder();

            var request = requestBuilder.GetTokenByCodeRequest("https://api.imgur.com/oauth2/token", "123code", "123",
                "1234");

            Assert.NotNull(request);
            Assert.Equal("https://api.imgur.com/oauth2/token", request.RequestUri.ToString());
            Assert.Equal(HttpMethod.Post, request.Method);
            Assert.NotNull(request.Content);

            var expected = await request.Content.ReadAsStringAsync().ConfigureAwait(false);

            Assert.Equal("client_id=123&client_secret=1234&grant_type=authorization_code&code=123code", expected);
        }
コード例 #4
0
        public async Task GetTokenByRefreshTokenRequest_WithRefreshTokenEqual()
        {
            var requestBuilder = new OAuth2RequestBuilder();

            var request = requestBuilder.GetTokenByRefreshTokenRequest("https://api.imgur.com/oauth2/token",
                "ABChjfhjhjdhfjksdfsdfsdfs", "123", "1234");

            Assert.NotNull(request);
            Assert.Equal("https://api.imgur.com/oauth2/token", request.RequestUri.ToString());
            Assert.Equal(HttpMethod.Post, request.Method);
            Assert.NotNull(request.Content);

            var expected = await request.Content.ReadAsStringAsync().ConfigureAwait(false);

            Assert.Equal(
                "client_id=123&client_secret=1234&grant_type=refresh_token&refresh_token=ABChjfhjhjdhfjksdfsdfsdfs",
                expected);
        }
コード例 #5
0
        public void GetTokenByRefreshTokenRequest_WithEndpointUrlNull_ThrowsArgumentNullException()
        {
            var requestBuilder = new OAuth2RequestBuilder();

            var exception =
                Record.Exception(
                    () =>
                        requestBuilder.GetTokenByRefreshTokenRequest(null, "ABChjfhjhjdhfjksdfsdfsdfs", "clientId",
                            "clientSecret"));
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);

            var argNullException = (ArgumentNullException) exception;
            Assert.Equal(argNullException.ParamName, "url");
        }