Ejemplo n.º 1
0
        public void GetNonhijackableUri_ReturnsOriginalUri(string originalUriString)
        {
            // Arrange
            var originalUri = new Uri(originalUriString);

            // Act
            var newUri = UriUtils.GetNonhijackableUri(originalUri);

            // Assert
            Assert.Equal(originalUriString, newUri.ToString());
            Assert.Same(originalUri, newUri);
        }
Ejemplo n.º 2
0
        public void GetNonhijackableUri_NormalizesPackagesVersion(string version)
        {
            // Arrange
            var id                = "abcd";
            var originalUri       = new Uri($"https://www.nuget.org/api/v2/Packages(Id='{id}',Version='{version}')");
            var normalizedVersion = NuGetVersion.Parse(version).ToNormalizedString();

            // Act
            var newUri = UriUtils.GetNonhijackableUri(originalUri);

            // Assert
            Assert.NotEqual(originalUri.ToString(), newUri.ToString());
            Assert.NotSame(originalUri, newUri);

            Assert.Equal($"https://www.nuget.org/api/v2/Packages?$filter=true and Id eq '{id}' and NormalizedVersion eq '{normalizedVersion}'&semVerLevel=2.0.0", newUri.ToString());
        }
 protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
 {
     request.RequestUri = UriUtils.GetNonhijackableUri(request.RequestUri);
     return(base.SendAsync(request, cancellationToken));
 }