Пример #1
0
        public void InitCommand_Success_V2Style_DestinationProvided()
        {
            // Arrange
            using (var testInfo = new TestInfo())
            {
                var packagesAtRoot        = testInfo.AddPackagesToSource(TestInfo.PackagesSet0, 0);
                var packagesAtIdDirectory = testInfo.AddPackagesToSource(TestInfo.PackagesSet1, 1);

                var args = new string[]
                {
                    "init",
                    testInfo.SourceFeed,
                    testInfo.DestinationFeed
                };

                // Act
                var result = CommandRunner.Run(
                    testInfo.NuGetExePath,
                    testInfo.WorkingPath,
                    string.Join(" ", args),
                    waitForExit: true);

                // Assert
                Util.VerifyResultSuccess(result);
                Util.VerifyPackagesExist(packagesAtRoot, testInfo.DestinationFeed);
                Util.VerifyPackagesExist(packagesAtIdDirectory, testInfo.DestinationFeed);
            }
        }
Пример #2
0
        public void InitCommand_Success_ExpandSwitch()
        {
            // Arrange
            using (var testInfo = new TestInfo())
            {
                var packages = testInfo.AddPackagesToSource();

                var args = new string[]
                {
                    "init",
                    testInfo.SourceFeed,
                    testInfo.DestinationFeed,
                    "-Expand"
                };

                // Act
                var result = CommandRunner.Run(
                    testInfo.NuGetExePath,
                    testInfo.WorkingPath,
                    string.Join(" ", args),
                    waitForExit: true);

                // Assert
                Util.VerifyResultSuccess(result);
                Util.VerifyExpandedLegacyTestPackagesExist(packages, testInfo.DestinationFeed);
            }
        }
Пример #3
0
        public void InitCommand_Success_DestinationInvalidOnWindows()
        {
            // Arrange
            using (var testFolder = TestDirectory.Create())
                using (var destinationFolder = TestDirectory.Create())
                    using (var testInfo = new TestInfo(testFolder,
                                                       Path.Combine(destinationFolder, "foo|<>|bar")))
                    {
                        var packages = testInfo.AddPackagesToSource();

                        var args = new string[]
                        {
                            "init",
                            testInfo.SourceFeed,
                            testInfo.DestinationFeed,
                        };

                        // Act
                        var result = CommandRunner.Run(
                            testInfo.NuGetExePath,
                            testInfo.WorkingPath,
                            string.Join(" ", args),
                            waitForExit: true);

                        // Assert
                        Util.VerifyResultSuccess(result);
                        Util.VerifyPackagesExist(packages, testInfo.DestinationFeed);
                    }
        }
Пример #4
0
        public void InitCommand_Success_SourceIsRelative()
        {
            // Arrange
            using (var testInfo = new TestInfo())
            {
                var packages = testInfo.AddPackagesToSource();

                var args = new string[]
                {
                    "init",
                    ".",
                    testInfo.DestinationFeed
                };

                // Act
                var result = CommandRunner.Run(
                    testInfo.NuGetExePath,
                    testInfo.SourceFeed, // Source Feed is the working path
                    string.Join(" ", args),
                    waitForExit: true);

                // Assert
                Util.VerifyResultSuccess(result);
                Util.VerifyPackagesExist(packages, testInfo.DestinationFeed);
            }
        }
Пример #5
0
        public void InitCommand_Success_DestinationAlreadyContainsInvalidPackages()
        {
            // Arrange
            using (var testInfo = new TestInfo())
            {
                var packages = testInfo.AddPackagesToSource();

                var args = new string[]
                {
                    "init",
                    testInfo.SourceFeed,
                    testInfo.DestinationFeed
                };

                // Act
                var result = CommandRunner.Run(
                    testInfo.NuGetExePath,
                    testInfo.WorkingPath,
                    string.Join(" ", args),
                    waitForExit: true);

                // Assert
                Util.VerifyPackagesExist(packages, testInfo.DestinationFeed);

                var firstPackage       = packages.First();
                var packageId          = firstPackage.Id.ToLowerInvariant();
                var packageIdDirectory = Path.Combine(testInfo.DestinationFeed, packageId);
                Assert.True(Directory.Exists(packageIdDirectory));

                var packageVersion          = firstPackage.Version.ToNormalizedString();
                var packageVersionDirectory = Path.Combine(packageIdDirectory, packageVersion);
                Assert.True(Directory.Exists(packageVersionDirectory));

                var nupkgFileName = Util.GetNupkgFileName(packageId, packageVersion);
                var nupkgFilePath = Path.Combine(packageVersionDirectory, nupkgFileName);
                File.Delete(nupkgFilePath);

                // Main Act
                result = CommandRunner.Run(
                    testInfo.NuGetExePath,
                    testInfo.WorkingPath,
                    string.Join(" ", args),
                    waitForExit: true);

                // Main Assert
                Util.VerifyResultSuccess(result, string.Format(
                                             NuGetResources.AddCommand_ExistingPackageInvalid,
                                             firstPackage.ToString(),
                                             testInfo.DestinationFeed));

                var output = result.Item2;
                foreach (var p in packages.Skip(1))
                {
                    output.Contains(string.Format(
                                        NuGetResources.AddCommand_PackageAlreadyExists,
                                        p.ToString(),
                                        testInfo.DestinationFeed));
                }
            }
        }
Пример #6
0
        public void InitCommand_Success_DestinationDoesNotExist()
        {
            // Arrange
            using (var testFolder = TestFileSystemUtility.CreateRandomTestFolder())
                using (var destinationFolder = TestFileSystemUtility.CreateRandomTestFolder())
                    using (var testInfo = new TestInfo(testFolder,
                                                       Path.Combine(destinationFolder, "DoesNotExistSubFolder")))
                    {
                        var packages = testInfo.AddPackagesToSource();

                        var args = new string[]
                        {
                            "init",
                            testInfo.SourceFeed,
                            testInfo.DestinationFeed,
                        };

                        // Act
                        var result = CommandRunner.Run(
                            testInfo.NuGetExePath,
                            testInfo.WorkingPath,
                            string.Join(" ", args),
                            waitForExit: true);

                        // Assert
                        Util.VerifyResultSuccess(result);
                        Util.VerifyPackagesExist(packages, testInfo.DestinationFeed);
                    }
        }
Пример #7
0
        public void InitCommand_Success_SourceContainsInvalidPackages()
        {
            // Arrange
            using (var testInfo = new TestInfo())
            {
                var packages = testInfo.AddPackagesToSource();

                // Add an invalid package. Following calls add an invalid package to SourceFeed.
                var invalidPackageIdentity = new PackageIdentity("Invalid", new NuGetVersion("1.0.0"));
                var invalidPackageFile     = Path.Combine(
                    testInfo.SourceFeed,
                    invalidPackageIdentity.Id + "." + invalidPackageIdentity.Version.ToString() + ".nupkg");

                File.WriteAllText(invalidPackageFile, string.Empty);

                var args = new string[]
                {
                    "init",
                    testInfo.SourceFeed,
                    testInfo.DestinationFeed
                };

                // Act
                var result = CommandRunner.Run(
                    testInfo.NuGetExePath,
                    testInfo.WorkingPath,
                    string.Join(" ", args),
                    waitForExit: true);

                // Assert
                var expectedWarningMessage = string.Format(
                    NuGetResources.NupkgPath_InvalidNupkg,
                    invalidPackageFile);

                Util.VerifyResultSuccess(
                    result,
                    expectedOutputMessage: expectedWarningMessage);

                Util.VerifyPackagesExist(packages, testInfo.DestinationFeed);

                // Verify that the invalid package was not copied
                Util.VerifyPackageDoesNotExist(invalidPackageIdentity, testInfo.DestinationFeed);
            }
        }
Пример #8
0
        public void InitCommand_Success_DestinationAlreadyContainsPackages()
        {
            // Arrange
            using (var testInfo = new TestInfo())
            {
                var packages = testInfo.AddPackagesToSource();

                var args = new string[]
                {
                    "init",
                    testInfo.SourceFeed,
                    testInfo.DestinationFeed
                };

                // Act
                var result = CommandRunner.Run(
                    testInfo.NuGetExePath,
                    testInfo.WorkingPath,
                    string.Join(" ", args),
                    waitForExit: true);

                // Assert
                Util.VerifyPackagesExist(packages, testInfo.DestinationFeed);

                // Main Act
                result = CommandRunner.Run(
                    testInfo.NuGetExePath,
                    testInfo.WorkingPath,
                    string.Join(" ", args),
                    waitForExit: true);

                // Main Assert
                Util.VerifyResultSuccess(result);
                var output = result.Item2;
                foreach (var p in packages)
                {
                    output.Contains(string.Format(
                                        NuGetResources.AddCommand_PackageAlreadyExists,
                                        p.ToString(),
                                        testInfo.DestinationFeed));
                }
            }
        }