Exemplo n.º 1
0
        public void TestGetInstallationWhenNotExists()
        {
            // GIVEN the installation is not present
            mockIFileUtility.Setup(f => f.DirectoryExists(Path.Combine("a-dir", "pro", "core", "a-version"))).Returns(false);

            // WHEN I get the installation
            InstallationManager  classUnderTest = new InstallationManager(null, mockIFileUtility.Object, "a-dir", null);
            DarkRiftInstallation result         = classUnderTest.GetInstallation("a-version", ServerTier.Pro, "Core");

            // THEN the result is null
            Assert.IsNull(result);
        }
Exemplo n.º 2
0
        public void TestGetInstallationWhenExists()
        {
            // GIVEN the installation is present
            mockIFileUtility.Setup(f => f.DirectoryExists(Path.Combine("a-dir", "pro", "core", "a-version"))).Returns(true);

            // WHEN I get the installation
            InstallationManager  classUnderTest = new InstallationManager(null, mockIFileUtility.Object, "a-dir", null);
            DarkRiftInstallation result         = classUnderTest.GetInstallation("a-version", ServerTier.Pro, "Core");

            // THEN the result is a valid DarkRiftInstallation object
            Assert.AreEqual("a-version", result.Version);
            Assert.AreEqual(ServerTier.Pro, result.Tier);
            Assert.AreEqual("Core", result.Platform);
            Assert.AreEqual(Path.Combine("a-dir", "pro", "core", "a-version"), result.InstallationPath);
        }
Exemplo n.º 3
0
        private int Pull(PullOptions opts)
        {
            // If --list was specified, list installed versions and tell if documentation for that version is available locally
            if (opts.List)
            {
                PrintInstalledVersions();
                return 0;
            }

            string version;
            ServerTier tier;
            string platform;
            if (opts.Version == null)
            {
                // If version info was omitted, set parameters to current project settings
                if (context.Project?.Runtime != null)
                {
                    version = context.Project.Runtime.Version;
                    platform = context.Project.Runtime.Platform;
                    tier = context.Project.Runtime.Tier;
                }
                else
                {
                    Console.Error.WriteLine(Output.Red($"Couldn't find a version to install. To download latest version use 'latest'"));
                    return 1;
                }
            }
            else
            {
                version = opts.Version == "latest" ? installationManager.GetLatestDarkRiftVersion() : opts.Version;
                tier = opts.Pro ? ServerTier.Pro : ServerTier.Free;
                platform = opts.Platform;
            }

            // If --docs was specified, download documentation instead
            if (opts.Docs)
            {
                bool docsInstalled = documentationManager.GetInstallation(version) != null;
                if (docsInstalled && !opts.Force)
                {
                    Console.WriteLine(Output.Green($"Documentation for DarkRift {version} - {tier} (.NET {platform}) already installed! To force a reinstall use the option -f or --force"));
                }
                else
                {
                    if (documentationManager.Install(version, opts.Force) == null)
                    {
                        Console.Error.WriteLine(Output.Red($"Could not install the requested documentation."));
                        return 1;
                    }
                }
            }
            else
            {
                bool versionInstalled = installationManager.GetInstallation(version, tier, platform) != null;
                if (versionInstalled && !opts.Force)
                {
                    Console.WriteLine(Output.Green($"DarkRift {version} - {tier} (.NET {platform}) already installed! To force a reinstall use the option -f or --force"));
                }
                else
                {
                    if (installationManager.Install(version, tier, platform, opts.Force) == null)
                    {
                        Console.Error.WriteLine(Output.Red($"Could not install the requested version."));
                        return 1;
                    }
                }
            }

            return 0;
        }