Example #1
0
        private void ApplyPolicies()
        {
            var backups = _client.Get();

            if (backups == null || !backups.Any())
            {
                _logger.LogWarning("Backups not found.");
                return;
            }

            var currentDate = _clock.Now;
            var politician  = new Politician(backups, currentDate);

            var idsToRemove = politician.GetIdsToRemove();

            if (!idsToRemove.Any())
            {
                _logger.LogDebug($"Backups in actual state");
                return;
            }

            foreach (var id in idsToRemove)
            {
                _client.Remove(id);
                _logger.LogDebug($"Backup {id} was removed");
            }
        }
Example #2
0
        public void BackupWorking_Success()
        {
            for (var i = 0; i <= 1000; i++)
            {
                _clock.AddHours(12);
                _job.CreateBackup();

                var backups = _client.Get().GroupBy(x => x.GetGeneration(_clock.Now));
                foreach (var backup in backups)
                {
                    backup.Count().Should().BeLessOrEqualTo(backup.Key == BackupGeneration.Third ? 1 : 4);
                }
            }
        }