public void WillAppendTheApiPathWithIdToTheApiUri()
        {
            var cmdlet = new TestableGetRemotePackageVersionCommand
            {
                Id = "theId"
            };

            cmdlet.GetResults().Cast <string>();

            Assert.Equal("/api/v2/package-versions/theId", cmdlet.ActualApiEndpointUri.PathAndQuery);
        }
        public void WillAppendTheApiPathWithIdToTheApiUri()
        {
            var cmdlet = new TestableGetRemotePackageVersionCommand
            {
                Id = "theId"
            };

            cmdlet.GetResults().Cast<string>();

            Assert.Equal("/api/v2/package-versions/theId", cmdlet.ActualApiEndpointUri.PathAndQuery);
        }
        public void WillIncludeAPrereleaseQueryStringParameterInApiUriWhenPrereleaseParameterIsTrue()
        {
            var cmdlet = new TestableGetRemotePackageVersionCommand
            {
                Id = "theId",
                IncludePrerelease = true
            };

            cmdlet.GetResults().Cast<string>();

            Assert.Contains("includePrerelease=true", cmdlet.ActualApiEndpointUri.ToString());
        }
        public void WillUseTheSourceParameterWhenSpecified()
        {
            var cmdlet = new TestableGetRemotePackageVersionCommand
            {
                Id = "theId",
                Source = "http://theSourceParameterUri"
            };

            cmdlet.GetResults().Cast<string>();

            Assert.Equal("http://thesourceparameteruri", cmdlet.ActualApiEndpointUri.GetLeftPart(UriPartial.Authority));
        }
        public void WillNotIncludeAPrereleaseQueryStringParameterInApiUriWhenPrereleaseParameterIsFalse()
        {
            var cmdlet = new TestableGetRemotePackageVersionCommand
            {
                Id = "theId",
                IncludePrerelease = false
            };

            cmdlet.GetResults().Cast <string>();

            Assert.DoesNotContain("includePrerelease", cmdlet.ActualApiEndpointUri.ToString());
        }
        public void WillUseTheSourceParameterWhenSpecified()
        {
            var cmdlet = new TestableGetRemotePackageVersionCommand
            {
                Id     = "theId",
                Source = "http://theSourceParameterUri"
            };

            cmdlet.GetResults().Cast <string>();

            Assert.Equal("http://thesourceparameteruri", cmdlet.ActualApiEndpointUri.GetLeftPart(UriPartial.Authority));
        }
        public void WillWriteThePackageVersionsReturnedFromTheApiCall()
        {
            var cmdlet = new TestableGetRemotePackageVersionCommand
            {
                Id = "theId",
                StubResults = new string[]
                {
                    "1.0",
                    "2.0"
                }
            };

            var result = cmdlet.GetResults().Cast<string>();

            Assert.Equal("1.0", result.First());
            Assert.Equal("2.0", result.ElementAt(1));
        }
        public void WillWriteThePackageVersionsReturnedFromTheApiCall()
        {
            var cmdlet = new TestableGetRemotePackageVersionCommand
            {
                Id          = "theId",
                StubResults = new string[]
                {
                    "1.0",
                    "2.0"
                }
            };

            var result = cmdlet.GetResults().Cast <string>();

            Assert.Equal("1.0", result.First());
            Assert.Equal("2.0", result.ElementAt(1));
        }
        public void WillUseTheRepositoryPackagesWhenTheRepositoryIsNotHttpBased()
        {
            var cmdlet = new TestableGetRemotePackageVersionCommand
            {
                Id = "theId",
                StubPackageSource      = "c:\\aPackageDir",
                StubRepositoryPackages = new IPackage[]
                {
                    CreateStubPackage("theId", "1.0"),
                    CreateStubPackage("theId", "2.0"),
                }
            };

            var result = cmdlet.GetResults().Cast <string>();

            Assert.Equal("1.0", result.First());
            Assert.Equal("2.0", result.ElementAt(1));
        }
        public void WillNotIncludeRepositoryPackagesWithPrereleaseVersionsWhenNotFlagged()
        {
            var cmdlet = new TestableGetRemotePackageVersionCommand
            {
                Id = "theId",
                IncludePrerelease      = false,
                StubPackageSource      = "c:\\aPackageDir",
                StubRepositoryPackages = new IPackage[]
                {
                    CreateStubPackage("theId", "1.0"),
                    CreateStubPackage("theId", "2.0-pre"),
                }
            };

            var result = cmdlet.GetResults().Cast <string>();

            Assert.Equal("1.0", result.First());
            Assert.Equal(1, result.Count());
        }
        public void WillAggregateResultsWhenThePackageRepositoryIsAnAggregateRepository()
        {
            var cmdlet = new TestableGetRemotePackageVersionCommand()
            {
                Id          = "theId",
                StubResults = new string[]
                {
                    "1.0",
                    "2.0-pre"
                },
                StubPackageRepository = new AggregateRepository(
                    new[]
                {
                    CreateStubPackageRepository(
                        new []
                    {
                        CreateStubPackage("theId", "1.0"),
                        CreateStubPackage("theId", "2.0-pre"),
                    },
                        "http://theuri"),
                    CreateStubPackageRepository(
                        new []
                    {
                        CreateStubPackage("theId", "3.0"),
                        CreateStubPackage("theId", "4.0"),
                    },
                        "c:\\packages"),
                }),
            };

            var result = cmdlet.GetResults().Cast <string>();

            Assert.Contains("1.0", result);
            Assert.Contains("2.0-pre", result);
            Assert.Contains("3.0", result);
            Assert.Contains("4.0", result);
        }
        public void WillAggregateResultsWhenThePackageRepositoryIsAnAggregateRepository()
        {
            var cmdlet = new TestableGetRemotePackageVersionCommand()
            {
                Id = "theId",
                StubResults = new string[]
                {
                    "1.0",
                    "2.0-pre"
                },
                StubPackageRepository = new AggregateRepository(
                    new[]
                    {
                        CreateStubPackageRepository(
                            new []
                            {
                                CreateStubPackage("theId", "1.0"),
                                CreateStubPackage("theId", "2.0-pre"),
                            },
                            "http://theuri"),
                        CreateStubPackageRepository(
                            new []
                            {
                                CreateStubPackage("theId", "3.0"),
                                CreateStubPackage("theId", "4.0"),
                            },
                            "c:\\packages"),
                    }),
            };

            var result = cmdlet.GetResults().Cast<string>();

            Assert.Contains("1.0", result);
            Assert.Contains("2.0-pre", result);
            Assert.Contains("3.0", result);
            Assert.Contains("4.0", result);
        }
        public void WillNotIncludeRepositoryPackagesWithPrereleaseVersionsWhenNotFlagged()
        {
            var cmdlet = new TestableGetRemotePackageVersionCommand
            {
                Id = "theId",
                IncludePrerelease = false,
                StubPackageSource = "c:\\aPackageDir",
                StubRepositoryPackages = new IPackage[]
                {
                    CreateStubPackage("theId", "1.0"),
                    CreateStubPackage("theId", "2.0-pre"),
                }
            };

            var result = cmdlet.GetResults().Cast<string>();

            Assert.Equal("1.0", result.First());
            Assert.Equal(1, result.Count());
        }
        public void WillUseTheRepositoryPackagesWhenTheRepositoryIsNotHttpBased()
        {
            var cmdlet = new TestableGetRemotePackageVersionCommand
            {
                Id = "theId",
                StubPackageSource = "c:\\aPackageDir",
                StubRepositoryPackages = new IPackage[]
                {
                    CreateStubPackage("theId", "1.0"),
                    CreateStubPackage("theId", "2.0"),
                }
            };

            var result = cmdlet.GetResults().Cast<string>();

            Assert.Equal("1.0", result.First());
            Assert.Equal("2.0", result.ElementAt(1));
        }