public void TestBackup() { var environmentRepository = new EnvironmentRepository(connectionString); EnvironmentBackupper.Backup(environmentRepository); var backedUpEnvironment = environmentRepository.GetBackupEnvironments().FirstOrDefault(); Assert.NotNull(backedUpEnvironment); Assert.Null(backedUpEnvironment.EnvironmentVariables.FirstOrDefault(v => v.Name == "_CHAMI_ENV")); // We remove the environment we just added to make sure we can execute this test again. environmentRepository.DeleteEnvironmentById(backedUpEnvironment.EnvironmentId); }
/// <summary> /// Deletes the <see cref="Environment"/> corresponding to the supplied <see cref="EnvironmentViewModel"/> from the datastore. /// </summary> /// <param name="selectedEnvironment">The <see cref="EnvironmentViewModel"/> to delete from the datastore.</param> /// <returns>If the <see cref="EnvironmentViewModel"/> is null or its id is 0, returns false. Otherwise, returns whether the deletion was successful or not.</returns> public bool DeleteEnvironment(EnvironmentViewModel selectedEnvironment) { if (selectedEnvironment == null) { return(false); } int id = selectedEnvironment.Id; if (id == 0) { return(false); } var removed = _repository.DeleteEnvironmentById(id); return(removed); }