Exemple #1
0
        public void PowerShellTests_WhenInvokingMoveFilesPowerShellScriptThroughWorkflowShouldCreateFoldersAndMoveFiles()
        {
            // Create an instance of our test workflow
            var workflow = new InvokeNugetterPowerShellScriptWorkflow();

            // Create the workflow run-time environment
            var workflowInvoker = new WorkflowInvoker(workflow);

            const string testPowerShellScript = "PSTest2MoveFiles.ps1";
            const string dummyTestFile01      = "DummyTestFile01.dat";

            var           newDir        = Path.Combine(TestContext.DeploymentDirectory, @"..\..", "TestDir");
            DirectoryInfo directoryInfo = Directory.CreateDirectory(newDir);

            var srcFile  = Path.Combine(TestContext.DeploymentDirectory, testPowerShellScript);
            var destFile = Path.Combine(directoryInfo.FullName, testPowerShellScript);

            if (File.Exists(destFile))
            {
                File.Delete(destFile);
            }

            File.Copy(srcFile, destFile);

            srcFile  = Path.Combine(TestContext.DeploymentDirectory, dummyTestFile01);
            destFile = Path.Combine(directoryInfo.FullName, dummyTestFile01);

            if (File.Exists(destFile))
            {
                File.Delete(destFile);
            }

            File.Copy(srcFile, destFile);


            // Set the workflow arguments
            workflow.DropFolder               = directoryInfo.FullName;
            workflow.BinariesFolder           = directoryInfo.FullName;
            workflow.SourcesFolder            = directoryInfo.FullName;
            workflow.PowerShellScriptFilePath = Path.Combine(directoryInfo.FullName, testPowerShellScript);

            // Invoke the workflow and capture the outputs
            var output = workflowInvoker.Invoke();

            var result = (string)output["PowerShellTestResult"];

            Assert.AreEqual("NGPS-Success", result);

            var packageFolder = Path.Combine(directoryInfo.FullName, "PackageFolder");

            Assert.IsTrue(Directory.Exists(packageFolder), "TestFolder2 Creation Failed");
            Assert.IsTrue(File.Exists(Path.Combine(packageFolder, "DummyTestFile01.dat")), "DummyTestFile01.dat Move Failed");
        }
        public void PowerShellTests_WhenInvokingMoveFilesPowerShellScriptThroughWorkflowShouldCreateFoldersAndMoveFiles()
        {
            // Create an instance of our test workflow
            var workflow = new InvokeNugetterPowerShellScriptWorkflow();

            // Create the workflow run-time environment
            var workflowInvoker = new WorkflowInvoker(workflow);

            const string testPowerShellScript = "PSTest2MoveFiles.ps1";
            const string dummyTestFile01 = "DummyTestFile01.dat";

            var newDir = Path.Combine(TestContext.DeploymentDirectory, @"..\..", "TestDir");
            DirectoryInfo directoryInfo = Directory.CreateDirectory(newDir);

            var srcFile = Path.Combine(TestContext.DeploymentDirectory, testPowerShellScript);
            var destFile = Path.Combine(directoryInfo.FullName, testPowerShellScript);

            if (File.Exists(destFile))
            {
                File.Delete(destFile);
            }

            File.Copy(srcFile, destFile);

            srcFile = Path.Combine(TestContext.DeploymentDirectory, dummyTestFile01);
            destFile = Path.Combine(directoryInfo.FullName, dummyTestFile01);

            if (File.Exists(destFile))
            {
                File.Delete(destFile);
            }

            File.Copy(srcFile, destFile);

            // Set the workflow arguments
            workflow.DropFolder = directoryInfo.FullName;
            workflow.BinariesFolder = directoryInfo.FullName;
            workflow.SourcesFolder = directoryInfo.FullName;
            workflow.PowerShellScriptFilePath = Path.Combine(directoryInfo.FullName, testPowerShellScript);

            // Invoke the workflow and capture the outputs
            var output = workflowInvoker.Invoke();

            var result = (string)output["PowerShellTestResult"];

            Assert.AreEqual("NGPS-Success", result);

            var packageFolder = Path.Combine(directoryInfo.FullName, "PackageFolder");

            Assert.IsTrue(Directory.Exists(packageFolder), "TestFolder2 Creation Failed");
            Assert.IsTrue(File.Exists(Path.Combine(packageFolder, "DummyTestFile01.dat")), "DummyTestFile01.dat Move Failed");
        }