/// <summary>
        /// Adds a new MSI install test step.
        /// </summary>
        /// <param name="testStep">The test step.</param>
        public void Add(MsiInstallTestStep testStep)
        {
            VerifySchemaVersion();

            var result = StoredTestSteps.Add(testStep) as MsiInstallTestStep;
            Debug.Assert(result != null, "The test step should be a MSI install test step.");

            Patch(result);
        }
        public void Install()
        {
            RetrieveFileDataForTestStep testFileLocation = index => @"c:\a\b";
            UploadReportFilesForTestStep uploader = (index, upload) => { };

            var runner = new Mock<IRunConsoleApplications>();
            {
                runner.Setup(r => r.Run(It.IsAny<string>(), It.IsAny<string[]>()))
                    .Callback(() => runner.Raise(r => r.OnConsoleOutput += null, new ProcessOutputEventArgs("foo")))
                    .Returns(0);
            }

            var fileSystem = new MockFileSystem(
                new Dictionary<string, MockFileData>
                    {
                        {
                            @"c:\a\b\c.msi", new MockFileData("Test file")
                        }
                    });

            var sectionBuilder = new Mock<ITestSectionBuilder>();
            var diagnostics = new SystemDiagnostics((p, s) => { }, null);
            var installer = new MsiDeployTestStepProcessor(
                testFileLocation,
                uploader,
                diagnostics,
                runner.Object,
                fileSystem,
                sectionBuilder.Object);

            var parameters = new List<TestStepParameter>
                {
                    new TestStepParameter
                        {
                            Key = "Key",
                            Value = "Value",
                        },
                };

            var data = new MsiInstallTestStep
            {
                pk_TestStepId = 1,
                Order = 2,
                TestStepParameters = parameters,
            };

            var result = installer.Process(data, new List<InputParameter>());
            Assert.AreEqual(TestExecutionState.Passed, result);
        }
        public void InstallWithExceptionInConsoleRunner()
        {
            RetrieveFileDataForTestStep testFileLocation = index => @"c:\a\b";
            UploadReportFilesForTestStep uploader = (index, upload) => { };

            var runner = new Mock<IRunConsoleApplications>();
            {
                runner.Setup(r => r.Run(It.IsAny<string>(), It.IsAny<string[]>()))
                    .Throws<NotImplementedException>();
            }

            var fileSystem = new MockFileSystem(
                new Dictionary<string, MockFileData>
                    {
                        {
                            @"c:\a\b\c.msi", new MockFileData("Test file")
                        }
                    });

            var sectionBuilder = new Mock<ITestSectionBuilder>();
            var diagnostics = new SystemDiagnostics((p, s) => { }, null);

            var installer = new MsiDeployTestStepProcessor(
                testFileLocation,
                uploader,
                diagnostics,
                runner.Object,
                fileSystem,
                sectionBuilder.Object);

            var data = new MsiInstallTestStep
                {
                    pk_TestStepId = 1,
                    Order = 2,
                };

            var result = installer.Process(data, new List<InputParameter>());
            Assert.AreEqual(TestExecutionState.Failed, result);
        }
        private MsiInstallTestStep Patch(MsiInstallTestStep msiTestStep)
        {
            var result = Patch((TestStep)msiTestStep) as MsiInstallTestStep;
            Debug.Assert(result != null, "The test step should be an MSI install test step.");

            return result;
        }
 private void Update(MsiInstallTestStep stored, MsiInstallTestStep changed)
 {
     var shouldPatch = Update(stored as TestStep, changed as TestStep);
     if (shouldPatch)
     {
         stored.IsPatched = false;
         Patch(stored);
     }
 }
Ejemplo n.º 6
0
        private static TestStep CopyStepAndStripNonEssentialInformation(TestStep step)
        {
            var parameters = new List<TestStepParameter>();
            foreach (var parameter in step.Parameters)
            {
                parameters.Add(
                    new TestStepParameter
                    {
                        Key = parameter.Key,
                        Value = parameter.Value,
                    });
            }

            var reportDirectories = new List<TestStepReportDirectory>();
            foreach (var directory in step.ReportDirectories)
            {
                reportDirectories.Add(
                    new TestStepReportDirectory
                    {
                        Path = directory.Path,
                    });
            }

            var reportFiles = new List<TestStepReportFile>();
            foreach (var file in step.ReportFiles)
            {
                reportFiles.Add(
                    new TestStepReportFile
                    {
                        Path = file.Path,
                    });
            }

            TestStep result = null;
            var consoleStep = step as ConsoleExecuteTestStep;
            if (consoleStep != null)
            {
                var newStep = new ConsoleExecuteTestStep
                {
                    Order = step.Order,
                    FailureMode = step.FailureMode,
                    ReportIncludesSystemLog = step.ReportIncludesSystemLog,
                    ExecutableFilePath = consoleStep.ExecutableFilePath,
                };

                result = newStep;
            }

            var msiStep = step as MsiInstallTestStep;
            if (msiStep != null)
            {
                var newStep = new MsiInstallTestStep
                {
                    Order = step.Order,
                    FailureMode = step.FailureMode,
                    ReportIncludesSystemLog = step.ReportIncludesSystemLog,
                };

                result = newStep;
            }

            var scriptStep = step as ScriptExecuteTestStep;
            if (scriptStep != null)
            {
                var newStep = new ScriptExecuteTestStep
                {
                    Order = step.Order,
                    FailureMode = step.FailureMode,
                    ReportIncludesSystemLog = step.ReportIncludesSystemLog,
                    ScriptLanguage = scriptStep.ScriptLanguage,
                };

                result = newStep;
            }

            var xcopyStep = step as XCopyTestStep;
            if (xcopyStep != null)
            {
                var newStep = new XCopyTestStep
                {
                    Order = step.Order,
                    FailureMode = step.FailureMode,
                    ReportIncludesSystemLog = step.ReportIncludesSystemLog,
                    Destination = xcopyStep.Destination,
                };

                result = newStep;
            }

            result.Parameters = parameters;
            result.ReportDirectories = reportDirectories;
            result.ReportFiles = reportFiles;
            return result;
        }
Ejemplo n.º 7
0
        public int RegisterMsi(int environment, int order, string failureMode, bool shouldIncludeSystemLog)
        {
            var testStep = new MsiInstallTestStep
                {
                    Order = order,
                    TestEnvironmentId = environment,
                    FailureMode = (TestStepFailureMode)Enum.Parse(typeof(TestStepFailureMode), failureMode),
                    ReportIncludesSystemLog = shouldIncludeSystemLog,
                };

            try
            {
                m_Context.Add(testStep);
                m_Context.StoreChanges();
            }
            catch (Exception e)
            {
                m_Diagnostics.Log(
                    LevelToLog.Error,
                    WebApiConstants.LogPrefix,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        "Registering the MSI test step failed with error: {0}",
                        e));

                throw;
            }

            return testStep.Id;
        }