コード例 #1
0
        public void SettingPathSetsEnvironmentVariable()
        {
            //setting path to a random string
            var randomString = RandomStringGenerator.Generate();
            var parameters   = new List <CmdletParameter>
            {
                new CmdletParameter()
                {
                    Name        = "Path",
                    SingleValue = randomString
                }
            };

            var powershell = new CmdletRunspace().CreatePowershellcmdlet(CmdletName, CmdletType, parameters);

            powershell.Invoke();

            //making sure the cmdlet set the Octopus tools Folder env variable == randomString
            Assert.AreEqual(randomString, OctoposhEnvVariables.OctopusToolsFolder);
        }
コード例 #2
0
        public void SetPathUsingPipelineInput()
        {
            var randomPath = RandomStringGenerator.Generate();

            //This test is trying to proof that the values returned by Get-OctopusToolVersion can be piped into Set-OctopusToolPath
            //Instead of calling Get-OctopusToolVersion, we'll simply create a fake OctopusToolVersion object and pipe that one to Set-OctopusToolPath
            var pipelineObjects = new List <OctopusToolVersion>()
            {
                new OctopusToolVersion()
                {
                    Path    = randomPath,
                    Version = Version.Parse("1.0.0")
                }
            };

            var powershell = new CmdletRunspace().CreatePowershellcmdlet(CmdletName, CmdletType);

            powershell.Invoke(pipelineObjects);

            //Making sure the Environment variable path has the same value a the path of the object sent through the pipeline.
            Assert.AreEqual(randomPath, OctoposhEnvVariables.Octoexe);
        }
コード例 #3
0
        public void SetPathByPath()
        {
            //setting path to a random string
            var randomString = RandomStringGenerator.Generate();

            var parameters = new List <CmdletParameter>
            {
                new CmdletParameter()
                {
                    Name        = "Path",
                    SingleValue = randomString
                }
            };

            var powershell = new CmdletRunspace().CreatePowershellcmdlet(CmdletName, CmdletType, parameters);

            //Running the cmdlet should set the $env:OctoExe variable value == randomString
            powershell.Invoke();

            //making sure environment variable was set to randomString
            Assert.AreEqual(OctoposhEnvVariables.Octoexe, randomString);
        }