public void DoBackup_SavesTestDataToTempDestination() { // Arrange var crh = new ClientRegistrationHelper("ShareUser", "1q2w3e", "sharedFolder"); var logger = new ConsoleLogger(); var backupConfig = new BackupConfig { SourceFolderPath = crh.ClientInfo.SharedFolderPath, SourceCredential = crh.ClientInfo.CredentialInfo, DestinationFolderPath = DestinationPath, DestinationCredential = crh.ClientInfo.CredentialInfo }; var backupStrategy = new BackupStrategyCopyFiles(logger); // Act backupStrategy.DoWork(backupConfig); // Assert var filesInSource = Directory.EnumerateFiles(backupConfig.SourceFolderPath); Assert.IsNotNull(filesInSource); var filesInDestination = Directory.EnumerateFiles(backupConfig.DestinationFolderPath); Assert.IsNotNull(filesInDestination); foreach (var fileName in filesInSource.Select(Path.GetFileName)) { Assert.IsTrue(filesInDestination.Any(f => f.Contains(fileName))); } }
/// <summary> /// Gets the scheduled backups for newly registered client. /// </summary> /// <param name="sourceClientInfo">The source client information.</param> /// <returns>List of scheduled backups.</returns> private IEnumerable <ScheduledBackup> GetScheduledBackupsForNewlyRegisteredClient(ClientInfo sourceClientInfo) { var scheduledBackups = new List <ScheduledBackup>(); var destinationFolder = sourceClientInfo.ClientIpAddress; var destinationPath = Path.Combine("serverSharedFolder", destinationFolder); var destinationRegistrationHelper = new ClientRegistrationHelper( "ServerUser", "1q2w3e", destinationPath); var destinationClientInfo = destinationRegistrationHelper.ClientInfo; var backupConfig = new BackupConfig { ClientIpAddress = destinationClientInfo.ClientIpAddress, DestinationCredential = destinationClientInfo.CredentialInfo, DestinationFolderPath = destinationClientInfo.SharedFolderPath, SourceCredential = sourceClientInfo.CredentialInfo, SourceFolderPath = sourceClientInfo.SharedFolderPath }; var lastScheduled = DateTime.UtcNow; for (int i = 0; i < 10; i++) { var scheduledBackup = new ScheduledBackup(lastScheduled, backupConfig); scheduledBackups.Add(scheduledBackup); lastScheduled = lastScheduled.AddHours(1); } return(scheduledBackups); }
/// <summary> /// Initializes a new instance of the <see cref="RemoteRequestsFacade" /> class. /// </summary> /// <param name="requestManager">The request manager.</param> /// <param name="clientRegistrationHelper">The client registration helper.</param> public RemoteRequestsFacade(IRequestManager requestManager, ClientRegistrationHelper clientRegistrationHelper) { Requires.NotNull(requestManager, nameof(requestManager)); Requires.NotNull(clientRegistrationHelper, nameof(clientRegistrationHelper)); Requires.NotNull(clientRegistrationHelper.ClientInfo, nameof(clientRegistrationHelper.ClientInfo)); Requires.NotNullOrEmpty(clientRegistrationHelper.ClientInfo.ClientIpAddress, nameof(clientRegistrationHelper.ClientInfo.ClientIpAddress)); _requestManager = requestManager; _clientInfo = clientRegistrationHelper.ClientInfo; SetAccessToken(_clientInfo); }