public void TestReactionTimeTimeContoroller() { var nowPlusSec = DateTime.Now + TimeSpan.FromSeconds(1); var testData = new TestedData(); var config = new Config() { schedulePeriod = TimeSpan.FromMilliseconds(400), reactionTime = new ReactionTime() { hour = nowPlusSec.Hour, minute = nowPlusSec.Minute, second = nowPlusSec.Second }, backupCondition = BackupCondition.AlwaysAtTheCertainTime }; var dataPlace = new DataPlace(testData.DirPath); var backupRule = new BackupRule(dataPlace, config); var backuperMock = new Mock <IBackuper>(); var timeController = new TimeController(config, backuperMock.Object); timeController.Start(); Thread.Sleep(1600); timeController.Stop(); backuperMock.Verify(backuper => backuper.Update(), Times.AtLeast(2)); }
public static Task <IEnumerable <FileInfo> > TraverseDirectoryWithFilterAsync( string rootDirPath, BackupRule backupRule, traverseFSFileAdded callback) { return(TraverseDirectoryWithFilterAsync( rootDirPath, backupRule.FilterIncludes, backupRule.FilterExcludes, callback )); }
public void TestRules() { var backupRule = new BackupRule(_dataPlace, _config); var actionMock = new Mock <IBackupAction>(); var backuper = new Backuper(actionMock.Object, backupRule); _testedData.ChangeFile(); Thread.Sleep(MoreTime); backuper.Update(); Thread.Sleep(MoreTime); backuper.Update(); actionMock.Verify(act => act.Backup(), Times.Once); }
public void TestEncryptedArchives() { var newConfig = _config; newConfig.usePassword = true; newConfig.password = "******"; newConfig.backupToPath += "\\test.zip"; var backupRule = new BackupRule(_dataPlace, newConfig); var backupAction = new BackupAction(_dataPlace, newConfig); var backuper = new Backuper(backupAction, backupRule); backupAction.Backup(); var verificator = new DataVerificator(_testedData); Assert.Catch <InvalidDataException>(() => verificator.testArchive(newConfig.backupToPath)); Assert.IsTrue(verificator.testEncryptedArchive(newConfig.backupToPath, newConfig.password)); }
public void TestTimeContoroller() { var testData = new TestedData(); var config = new Config() { schedulePeriod = TimeSpan.FromMilliseconds(500), backupCondition = BackupCondition.SchedulePeriodIfChanged }; var dataPlace = new DataPlace(testData.DirPath); var backupRule = new BackupRule(dataPlace, config); var backuperMock = new Mock <IBackuper>(); var timeController = new TimeController(config, backuperMock.Object); timeController.Start(); Thread.Sleep(1250); timeController.Stop(); backuperMock.Verify(backuper => backuper.Update(), Times.Exactly(2)); }
public static IEnumerable <FileInfo> TraverseDirectoryWithFilter(string rootDirPath, BackupRule backupRule) { return(TraverseDirectoryWithFilter( rootDirPath, backupRule.FilterIncludes, backupRule.FilterExcludes )); }