Beispiel #1
0
        public void ToRestRequestReturnsRestRequestWithCorrectParameters()
        {
            // Arrange
            var tokensUri = new Uri("/tokens", UriKind.Relative);
            var clientCredentialsGrantTokenRequest = new ClientCredentialsGrantTokenRequest(ClientId, ClientSecret, Scope);

            // Act
            var restRequest = clientCredentialsGrantTokenRequest.ToRestRequest(tokensUri);

            // Assert
            var expectedParameters = new List <Parameter>
            {
                new Parameter {
                    Name = "grant_type", Value = "client_credentials", Type = ParameterType.GetOrPost
                },
                new Parameter {
                    Name = "client_id", Value = ClientId, Type = ParameterType.GetOrPost
                },
                new Parameter {
                    Name = "client_secret", Value = ClientSecret, Type = ParameterType.GetOrPost
                },
                new Parameter {
                    Name = "scope", Value = Scope, Type = ParameterType.GetOrPost
                }
            };

            Assert.Equal(expectedParameters, restRequest.Parameters, new ParameterEqualityComparer());
        }
Beispiel #2
0
        public void ToRestRequestWithNullTokensUriThrowsArgumentNullException()
        {
            // Arrange
            Uri tokensUri = null;
            var clientCredentialsGrantTokenRequest = new ClientCredentialsGrantTokenRequest(ClientId, ClientSecret, Scope);

            // Act

            // Assert
            Assert.Throws <ArgumentNullException>(() => clientCredentialsGrantTokenRequest.ToRestRequest(tokensUri));
        }
Beispiel #3
0
        public void ToRestRequestReturnsRestRequestWithSpecifiedTokensUri()
        {
            // Arrange
            var tokensUri = new Uri("/tokens", UriKind.Relative);
            var clientCredentialsGrantTokenRequest = new ClientCredentialsGrantTokenRequest(ClientId, ClientSecret, Scope);

            // Act
            var restRequest = clientCredentialsGrantTokenRequest.ToRestRequest(tokensUri);

            // Assert
            Assert.Equal(tokensUri.ToString(), restRequest.Resource);
        }
Beispiel #4
0
        public void ToRestRequestReturnsRestRequestWithMethodIsPost()
        {
            // Arrange
            var tokensUri = new Uri("/tokens", UriKind.Relative);
            var clientCredentialsGrantTokenRequest = new ClientCredentialsGrantTokenRequest(ClientId, ClientSecret, Scope);

            // Act
            var restRequest = clientCredentialsGrantTokenRequest.ToRestRequest(tokensUri);

            // Assert
            Assert.Equal(Method.POST, restRequest.Method);
        }