private GetTokenByPinRequest ( string url, string pin, string clientId, string clientSecret ) : |
||
url | string | |
pin | string | |
clientId | string | |
clientSecret | string | |
return |
public void GetTokenByPinRequest_WithClientIdNull_ThrowsArgumentNullException() { var requestBuilder = new OAuth2RequestBuilder(); var exception = Record.Exception(() => requestBuilder.GetTokenByPinRequest("url", "123", null, "clientSecret")); Assert.NotNull(exception); Assert.IsType<ArgumentNullException>(exception); var argNullException = (ArgumentNullException) exception; Assert.Equal(argNullException.ParamName, "clientId"); }
public async Task GetTokenByPinRequest_WithPinEqual() { var requestBuilder = new OAuth2RequestBuilder(); var request = requestBuilder.GetTokenByPinRequest("https://api.imgur.com/oauth2/token", "4899", "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=pin&pin=4899", expected); }