Пример #1
0
        public void Should_GetAccessToken_QueryString()
        {
            // Arrange
            const string accessToken  = "access_token";
            var          accessMethod = new QueryStringAccessMethod();
            var          request      = new HttpRequestMessage {
                RequestUri = new Uri("https://host.com/")
            };

            // Act
            accessMethod.Set(request, accessToken);

            // Assert
            Assert.Equal(accessToken, accessMethod.Get(request));
        }
Пример #2
0
        public void Should_SetAccessToken_QueryString_Empty()
        {
            // Arrange
            const string accessToken  = "access_token";
            var          accessMethod = new QueryStringAccessMethod();
            var          request      = new HttpRequestMessage {
                RequestUri = new Uri("https://host.com/")
            };

            // Act
            accessMethod.Set(request, accessToken);

            // Assert
            var query = request.RequestUri.Query;

            Assert.Contains(QueryStringAccessMethod.ParameterKey, query);
            Assert.Contains(accessToken, query);
        }
Пример #3
0
        public void Should_SetAccessToken_QueryString_NotEmpty()
        {
            // Arrange
            const string accessToken  = "access_token";
            var          accessMethod = new QueryStringAccessMethod();
            var          request      = new HttpRequestMessage {
                RequestUri = new Uri("https://host.com/?param=value")
            };

            // Act
            accessMethod.Set(request, accessToken);

            // Assert
            var query = request.RequestUri.Query;

            // Is there a better way checking that the query string is valid?
            Assert.Equal(2, HttpUtility.ParseQueryString(query).Count);
            Assert.Contains(QueryStringAccessMethod.ParameterKey, query);
            Assert.Contains(accessToken, query);
        }