Exemplo n.º 1
0
    public void Serialize_Powershell_File_Task_With_Defaults_Test()
    {
        var task = new PowershellFileTask("some\\script.ps1").DisplayAs("Test task");

        string yaml = SharplinerSerializer.Serialize(task);

        yaml.Trim().Should().Be(
            "" "
            task: PowerShell@2

            displayName: Test task

            inputs:
              targetType: filePath
              filePath: some\script.ps1
            " "");
    }
Exemplo n.º 2
0
        public void Run_should_parse_localfile_paths(string inputFilePath, string expectedFilePath)
        {
            // given
            _fileProviderMock.CurrentDirectory = "c:\\currentdir";
            var task   = new PowershellFileTask(_fileProviderMock, _runnerMock);
            var config = new PowershellFileTaskConfig();

            var properties = new Dictionary <object, object>();

            properties["uri"] = inputFilePath;
            task.SetConfiguration(config, properties);

            // when
            task.Run(_logger);

            // then
            Assert.That(_runnerMock.ActualTempFilename, Is.EqualTo(expectedFilePath));
        }
Exemplo n.º 3
0
        public void Run_should_parse_and_run_remotefiles()
        {
            // given
            _fileProviderMock.DownloadContent = "echo hello-world";
            _fileProviderMock.TempFilePath    = "expected-tempfilename.ps1";
            var task = new PowershellFileTask(_fileProviderMock, _runnerMock);

            var config = new PowershellFileTaskConfig();

            var properties = new Dictionary <object, object>();

            properties["uri"] = "http://www.example.com/powershell.ps1";
            task.SetConfiguration(config, properties);

            // when
            task.Run(_logger);

            // then
            Assert.That(_runnerMock.ActualTempFilename, Is.EqualTo(_fileProviderMock.TempFilePath));
        }
Exemplo n.º 4
0
        public void SetConfiguration_should_set_config_from_properties()
        {
            // given
            var task   = new PowershellFileTask(_fileProviderMock, _runnerMock);
            var config = new PowershellFileTaskConfig();

            var properties = new Dictionary <object, object>();

            properties["uri"] = "http://www.example.com/powershell.ps1";

            // when
            task.SetConfiguration(config, properties);

            // then
            var actualconfig = task.Config as PowershellFileTaskConfig;

            Assert.That(actualconfig, Is.Not.Null);

            Assert.That(actualconfig.Uri, Is.EqualTo("http://www.example.com/powershell.ps1"));
        }
Exemplo n.º 5
0
    public void Serialize_Powershell_File_Task_Test()
    {
        var task = new PowershellFileTask("some\\script.ps1")
        {
            Arguments             = "foo bar",
            ContinueOnError       = true,
            ErrorActionPreference = ActionPreference.Inquire,
            WarningPreference     = ActionPreference.Stop,
            InformationPreference = ActionPreference.Break,
            DebugPreference       = ActionPreference.Suspend,
            VerbosePreference     = ActionPreference.Break,
            FailOnStderr          = true,
            IgnoreLASTEXITCODE    = true,
            DisplayName           = "Test task"
        };

        string yaml = SharplinerSerializer.Serialize(task);

        yaml.Trim().Should().Be(
            "" "
            task: PowerShell@2

            displayName: Test task

            inputs:
              targetType: filePath
              filePath: some\script.ps1
              arguments: foo bar
              errorActionPreference: Inquire
              warningPreference: Stop
              informationPreference: Break
              verbosePreference: Break
              debugPreference: Suspend
              failOnStderr: true
              ignoreLASTEXITCODE: true

            continueOnError: true
            " "");
    }
Exemplo n.º 6
0
        public void should_have_yaml_name()
        {
            var task = new PowershellFileTask(_fileProviderMock, _runnerMock);

            Assert.That(task.YamlName, Is.EqualTo("powershell-file"));
        }