Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #3
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);
        }
        /// <summary>
        /// Prints version information on the console
        /// </summary>
        /// <param name="installation">The installation to be printed.</param>
        /// <param name="isDocumentationInstalled">Whether the respective documentation for this version is installed.</param>
        private void PrintVersion(DarkRiftInstallation installation, bool isDocumentationInstalled)
        {
            string output = "";

            // There's no free or pro in documentation

            output += $"DarkRift {installation.Version} - {installation.Tier} (.NET {installation.Platform})";

            if (isDocumentationInstalled)
                output += " and its documentation are";
            else
                output += " is";

            output += " installed";

            Console.WriteLine(output);
        }
        private int Run(RunOptions opts)
        {
            // If we're not in a project then try our best to guess settings
            if (context.Project?.Runtime == null)
            {
                Console.Error.WriteLine(Output.Red("Unable to get desired runtime from project file, are you sure this is a DarkRift project?"));
                return 1;
            }

            DarkRiftInstallation installation = installationManager.Install(context.Project.Runtime.Version, context.Project.Runtime.Tier, context.Project.Runtime.Platform, false);
            if (installation == null)
            {
                Console.Error.WriteLine(Output.Red("Unable to find correct version of DarkRift locally and unable to download it."));
                return 1;
            }

            return installation.Run(opts.Values);
        }
Beispiel #6
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);
        }