public void The_deployment_directory_for_the_file_is_the_same_as_the_one_where_the_test_assemblies_are_deployed() { var deployedFile = TestFile.FromDeployedFile(DeployedTextFile1Name); var localPath = new Uri(GetType().Assembly.CodeBase).LocalPath; Assert.That(localPath, Is.SamePathOrUnder(deployedFile.DeploymentDirectory)); }
public void The_content_of_a_deployed_file_can_be_preserved_after_code_that_modify_the_file_is_invoked() { var textFile1 = TestFile.FromDeployedFile(DeployedTextFile1Name); textFile1.InvokeAndPreserve(() => File.WriteAllText(textFile1.FullName, "Modified content")); Assert.That(File.ReadAllText(textFile1.FullName), Is.EqualTo("This is deployed text file number 1")); }
public void A_deployed_file_can_be_backed_up() { var deployedFile = TestFile.FromDeployedFile(DeployedTextFile1Name); deployedFile.Backup(); Assert.That(File.Exists(deployedFile.BackupFullName), Is.True); }
public void The_content_of_a_deployed_file_can_be_preserved_after_code_that_runs_with_a_replaced_file_is_invoked() { var textFile1 = TestFile.FromDeployedFile(DeployedTextFile1Name); var anotherDeployedTextFile = TestFile.FromDeployedFile(DeployedTextFile2Name); textFile1.InvokeWithReplacement(anotherDeployedTextFile, () => File.WriteAllText(textFile1.FullName, "Modified content")); Assert.That(File.ReadAllText(textFile1.FullName), Is.EqualTo("This is deployed text file number 1")); }
public void A_deployed_file_can_be_deleted() { TestFile.FromDeployedFile(DeployedTextFile1Name).InvokeAndPreserve(deployedFile => { deployedFile.Delete(); Assert.That(File.Exists(deployedFile.FullName), Is.False); }); }
public void A_deployed_file_can_be_replaced_with_another_file() { TestFile.FromDeployedFile(DeployedTextFile1Name).InvokeAndPreserve(deployedFile => { var anotherDeployedTextFile = TestFile.FromDeployedFile(DeployedTextFile2Name); deployedFile.ReplaceWith(anotherDeployedTextFile); Assert.That(File.ReadAllText(deployedFile.FullName), Is.EqualTo("This is deployed text file number 2")); }); }
public void A_deployed_file_can_be_restored_from_backup() { var deployedFile = TestFile.FromDeployedFile(DeployedTextFile1Name); deployedFile.Backup(); File.Delete(deployedFile.FullName); deployedFile.Restore(); Assert.That(File.Exists(deployedFile.FullName)); }
public void A_deployed_configuration_file_can_replace_the_current_configuration() { TestFile.FromCurrentConfigurationFile().InvokeAndPreserve(currentConfigurationFile => { var deployedFile = TestFile.FromDeployedFile(DeployedConfigurationFileName); currentConfigurationFile.ReplaceWith(deployedFile); Assert.That(ConfigurationManager.AppSettings["DeployedConfiguration"], Is.EqualTo("This is a deployed configuration")); }); }
public void Restoring_a_file_that_is_not_backed_up_throws_an_exception() { Assert.Throws <FileNotFoundException>(() => { var deployedFile = TestFile.FromDeployedFile(DeployedTextFile1Name); if (File.Exists(deployedFile.BackupFullName)) { File.Delete(deployedFile.BackupFullName); } deployedFile.Restore(); }); }