/// <summary>
        /// Copy all files from target directory to 
        /// a new directory in the deployment target's 
        /// backup directory.
        /// Name new backup directory yyyy-mm-dd-hh-mm
        /// </summary>
        public PowerShellScriptResult Backup(DeploymentTarget target)
        {
            // make sortable directory name, replace reserved : with -
            var newDirectoryName = DateTime.Now.ToString("s").Replace(":", "-");
            var fullPathToBackupDirectory = Path.Combine(target.BackupDirectory, newDirectoryName);

            using (new Impersonator(this.userName, this.domain, this.password))
            {
                Directory.CreateDirectory(fullPathToBackupDirectory);
            }

            var scriptCommand = String.Format(@".\{0} -source '{1}' -target '{2}'",
                                this.backupScriptName, target.TargetDirectory, fullPathToBackupDirectory);
            var scriptResult = this.scriptRunner.RunScript(this.userName, this.password, this.domain,
                                    scriptCommand, this.scriptWorkingDirectory, this.timeoutMilliseconds);

            return scriptResult;
        }
        public void BackupTest()
        {
            var scriptDirectory = @"DeploymentScripts";
            var fullPathToScripts = Path.Combine(ScriptBaseDirectory, scriptDirectory);

            WebApplicationDeploymentService target = new WebApplicationDeploymentService(fullPathToScripts, "deploy.ps1", "backup.ps1", 1000 * 60 * 120,
                                                                                         "Jay", "", "4uze8ata");

            Application application = new Application
            {
                Name = "Cosmo"
            };

            DeploymentTarget target1 = new DeploymentTarget
            {
                BackupDirectory = Path.Combine(TestsBaseDirectory + @"\QA", @"Backups"),
                TargetDirectory = @"C:\Users\Jay\Documents\Visual Studio 2010\Projects\WebDeployer\Tests\QAwebserver\Cosmo"
            };
            target.Backup(target1);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
        public void DeployTest()
        {
            var scriptDirectory = @"DeploymentScripts";
            var fullPathToScripts = Path.Combine(ScriptBaseDirectory, scriptDirectory);

            WebApplicationDeploymentService service = new WebApplicationDeploymentService(fullPathToScripts, "deploy.ps1", "backup.ps1", 1000 * 60 * 120,
                                                                                         "Jay", "", "4uze8ata");

            Application application = new Application
            {
                Name = "Cosmo",
                ExcludeFiles = "*exclude*.* Web.config",
                ExcludeDirectories = "Log PDFs"
            };

            DeploymentTarget target = new DeploymentTarget
            {
                BackupDirectory = Path.Combine(TestsBaseDirectory + @"\PROD", @"Backups"),
                TargetDirectory = @"C:\Users\Jay\Documents\Visual Studio 2010\Projects\WebDeployer\Tests\PRODwebserver\Cosmo",
                SourceDirectory = Path.Combine(TestsBaseDirectory + @"\PROD", @"Deploy"),
                Application = application,
                Name = "PROD"
            };

            DeploymentRequest request = new DeploymentRequest
            {
                DeploymentTarget = target
            };

            var result = service.Deploy(request);

            //Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }
 public void Rollback(DeploymentTarget target)
 {
 }