Exemplo n.º 1
0
        private int New(NewOptions opts)
        {
            string version = opts.Version ?? installationManager.GetLatestDarkRiftVersion();
            ServerTier tier = opts.Pro ? ServerTier.Pro : ServerTier.Free;
            string targetDirectory = opts.TargetDirectory ?? Environment.CurrentDirectory;

            installationManager.Install(version, tier, opts.Platform, false);

            try
            {
                templater.Template(opts.Type, targetDirectory, version, tier, opts.Platform, opts.Force);
            }
            catch (DirectoryNotEmptyException)
            {
                Console.Error.WriteLine(Output.Red("Cannot create from template, the directory is not empty. Use -f to force creation."));
                Console.Error.WriteLine("\t" + Environment.GetCommandLineArgs()[0] + " " + Parser.Default.FormatCommandLine(new NewOptions { Type = opts.Type, TargetDirectory = opts.TargetDirectory, Force = true }));
                return 1;
            }
            catch (ArgumentException e)
            {
                Console.Error.WriteLine(Output.Red(e.Message));
                return 1;
            }

            return 0;
        }
Exemplo n.º 2
0
        public void TestInstallWhenDownloadFails()
        {
            // GIVEN the installation does not exist
            mockIFileUtility.Setup(f => f.DirectoryExists(Path.Combine("a-dir", "pro", "core", "a-version"))).Returns(false);

            // AND the installation is not available on the remote
            mockIRemoteRepository.Setup(r => r.DownloadVersionTo("a-version", ServerTier.Pro, "Core", Path.Combine("a-dir", "pro", "core", "a-version")))
            .Returns(false);

            // WHEN I install the version
            InstallationManager  classUnderTest = new InstallationManager(mockIRemoteRepository.Object, mockIFileUtility.Object, "a-dir", null);
            DarkRiftInstallation result         = classUnderTest.Install("a-version", ServerTier.Pro, "Core", false);

            // THEN null is returned
            Assert.IsNull(result);
        }
Exemplo n.º 3
0
        public void TestInstall()
        {
            // GIVEN the installation does not exist
            mockIFileUtility.Setup(f => f.DirectoryExists(Path.Combine("a-dir", "pro", "core", "a-version"))).Returns(false);

            // AND the installation is available on the remote
            mockIRemoteRepository.Setup(r => r.DownloadVersionTo("a-version", ServerTier.Pro, "Core", Path.Combine("a-dir", "pro", "core", "a-version")))
            .Returns(true);

            // WHEN I install the version
            InstallationManager  classUnderTest = new InstallationManager(mockIRemoteRepository.Object, mockIFileUtility.Object, "a-dir", null);
            DarkRiftInstallation result         = classUnderTest.Install("a-version", ServerTier.Pro, "Core", false);

            // THEN the download was run
            mockIRemoteRepository.Verify(r => r.DownloadVersionTo("a-version", ServerTier.Pro, "Core", Path.Combine("a-dir", "pro", "core", "a-version")));

            // AND the installation returned is correct
            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);
        }