Exemplo n.º 1
0
        public void GetHandlerHostOnlyTests()
        {
            var nodeData = new NodeHandlerData()
            {
                Platforms = new string[] { "linux", "osx" }
            };
            var nodeOnlyExecutionData = new ExecutionData();

            nodeOnlyExecutionData.Node = nodeData;
            var powerShell3Data = new PowerShell3HandlerData()
            {
                Platforms = new string[] { "windows" }
            };
            var ps3OnlyExecutionData = new ExecutionData();

            ps3OnlyExecutionData.PowerShell3 = powerShell3Data;
            var mixedExecutionData = new ExecutionData();

            mixedExecutionData.PowerShell3 = powerShell3Data;
            mixedExecutionData.Node        = nodeData;


            foreach (var test in new GetHandlerTest[] {
                new GetHandlerTest()
                {
                    Name = "Empty Test", Input = null, Expected = null, HostOS = PlatformUtil.OS.Windows
                },
                new GetHandlerTest()
                {
                    Name = "Node Only on Windows", Input = nodeOnlyExecutionData, Expected = nodeData, HostOS = PlatformUtil.OS.Windows
                },
                new GetHandlerTest()
                {
                    Name = "Node Only on Linux", Input = nodeOnlyExecutionData, Expected = nodeData, HostOS = PlatformUtil.OS.Linux
                },
                new GetHandlerTest()
                {
                    Name = "Node Only on OSX", Input = nodeOnlyExecutionData, Expected = nodeData, HostOS = PlatformUtil.OS.OSX
                },
                new GetHandlerTest()
                {
                    Name = "PowerShell3 Only on Windows", Input = ps3OnlyExecutionData, Expected = powerShell3Data, HostOS = PlatformUtil.OS.Windows
                },
                new GetHandlerTest()
                {
                    Name = "PowerShell3 Only on Linux", Input = ps3OnlyExecutionData, Expected = powerShell3Data, HostOS = PlatformUtil.OS.Linux
                },
                new GetHandlerTest()
                {
                    Name = "PowerShell3 Only on OSX", Input = ps3OnlyExecutionData, Expected = powerShell3Data, HostOS = PlatformUtil.OS.OSX
                },
                new GetHandlerTest()
                {
                    Name = "Mixed on Windows", Input = mixedExecutionData, Expected = powerShell3Data, HostOS = PlatformUtil.OS.Windows
                },
                new GetHandlerTest()
                {
                    Name = "Mixed on Linux", Input = mixedExecutionData, Expected = nodeData, HostOS = PlatformUtil.OS.Linux
                },
                new GetHandlerTest()
                {
                    Name = "Mixed on OSX", Input = mixedExecutionData, Expected = nodeData, HostOS = PlatformUtil.OS.OSX
                },
            })
            {
                using (TestHostContext hc = CreateTestContext(test.Name))
                {
                    test.RunTest(hc);
                }
            }
        }
Exemplo n.º 2
0
        public void GetHandlerContainerTargetPreferNodeDisabledTests()
        {
            var nodeData = new NodeHandlerData();
            var nodeOnlyExecutionData = new ExecutionData();

            nodeOnlyExecutionData.Node = nodeData;
            var powerShell3Data = new PowerShell3HandlerData()
            {
                Platforms = new string[] { "windows" }
            };
            var ps3OnlyExecutionData = new ExecutionData();

            ps3OnlyExecutionData.PowerShell3 = powerShell3Data;
            var mixedExecutionData = new ExecutionData();

            mixedExecutionData.Node        = nodeData;
            mixedExecutionData.PowerShell3 = powerShell3Data;

            ContainerInfo containerInfo = new ContainerInfo()
            {
            };

            foreach (var test in new GetHandlerTest[] {
                new GetHandlerTest()
                {
                    Name = "Empty Test", Input = null, Expected = null, HostOS = PlatformUtil.OS.Windows, StepTarget = containerInfo
                },
                new GetHandlerTest()
                {
                    Name = "Node Only on Windows", Input = nodeOnlyExecutionData, Expected = nodeData, HostOS = PlatformUtil.OS.Windows, StepTarget = containerInfo
                },
                new GetHandlerTest()
                {
                    Name = "Node Only on Linux", Input = nodeOnlyExecutionData, Expected = nodeData, HostOS = PlatformUtil.OS.Linux, StepTarget = containerInfo
                },
                new GetHandlerTest()
                {
                    Name = "Node Only on OSX", Input = nodeOnlyExecutionData, Expected = nodeData, HostOS = PlatformUtil.OS.OSX, StepTarget = containerInfo
                },
                new GetHandlerTest()
                {
                    Name = "PowerShell3 Only on Windows", Input = ps3OnlyExecutionData, Expected = powerShell3Data, HostOS = PlatformUtil.OS.Windows, StepTarget = containerInfo
                },
                new GetHandlerTest()
                {
                    Name = "PowerShell3 Only on Linux", Input = ps3OnlyExecutionData, Expected = powerShell3Data, HostOS = PlatformUtil.OS.Linux, StepTarget = containerInfo
                },
                new GetHandlerTest()
                {
                    Name = "PowerShell3 Only on OSX", Input = ps3OnlyExecutionData, Expected = powerShell3Data, HostOS = PlatformUtil.OS.OSX, StepTarget = containerInfo
                },
                new GetHandlerTest()
                {
                    Name = "Mixed on Windows", Input = mixedExecutionData, Expected = powerShell3Data, HostOS = PlatformUtil.OS.Windows, StepTarget = containerInfo
                },
                new GetHandlerTest()
                {
                    Name = "Mixed on Linux", Input = mixedExecutionData, Expected = nodeData, HostOS = PlatformUtil.OS.Linux, StepTarget = containerInfo
                },
                new GetHandlerTest()
                {
                    Name = "Mixed on OSX", Input = mixedExecutionData, Expected = nodeData, HostOS = PlatformUtil.OS.OSX, StepTarget = containerInfo
                },
            })
            {
                var variables = new Dictionary <string, VariableValue>();
                variables.Add("agent.preferPowerShellOnContainers", "true");
                using (TestHostContext hc = CreateTestContext(test.Name))
                {
                    test.RunTest(hc, variables);
                    Environment.SetEnvironmentVariable("AGENT_PREFER_POWERSHELL_ON_CONTAINERS", "true");
                    test.RunTest(hc);
                    Environment.SetEnvironmentVariable("AGENT_PREFER_POWERSHELL_ON_CONTAINERS", null);
                }
            }
        }